|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
I'm using ms sql 2k, and I'm trying to select the most recent entry into my database. Since each entry has a "RecordID" field that increments up with each entry, I was thinking I could use MAX to select the most recent entry. However, I'm having trouble implementing this. When I try
Code:
SELECT MAX(RecordID) FROM UserAccess; Code:
SELECT * FROM UserAccess WHERE MAX(RecordID); ![]()
__________________
--Dave-- U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM= |
|
#2
|
||||
|
||||
|
You might try just ordering the items by RecordID and then sorting in descending order and getting the first element. I don't use MS SQL, but in postgres it would be something like:
SELECT * FROM "UserAccess" ORDER BY RecordID DESC LIMIT 1 The syntax may be a little bit different in MS SQL, but there should be something very similar. HTH -b
__________________
PostgreSQL, it's what's for dinner... |
|
#3
|
||||
|
||||
|
Thanks Bcyde, that put me on the right track. In case anyone else needs to do something similar, my final working query was
Code:
SELECT TOP 1 * FROM UserRequest ORDER BY RecordID DESC ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > selecting from table using MAX |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|