Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using max with multple column query... 1

Status
Not open for further replies.

fergman

Technical User
Oct 19, 2000
91
US
I'm trying to find the max number in my ID column, in order to see what record is currently in use, the only way I know how to do it is using the SQL function max() here is my query, but it does not seem to work.

SQL= "SELECT MAX(reservations.id), reservations.department from reservations"

Is there a better way to do this? if not, how do I run this query and still have the other column data?
 
SELECT * FROM tblWhatEver WHERE ID in (SELECT MAX(ID) FROM tblWhatEver)

I think that is what you are asking. Gives you all the data where the ID is Max. Max is not going to work very well at all if you ID is a varchar or something.


As far as the best way ~ assuming that you are using a numberical field that is updated by a sequence or something, this way is fine. foo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top