Forum Moderators: open

Message Too Old, No Replies

Select a single record from database

I just want the next one not *

         

too much information

2:25 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a very large database where I need to select the First record only matching my criteria, not the entire set. Is there a way to so something like this?

Ex:
Select FIRST from database where status = 'notProcessed'

dotme

2:52 pm on Feb 5, 2005 (gmt 0)

10+ Year Member



I think you need an "ORDER BY" clause. If you know what field to sort by (a date field, for example) you can ORDER BY datefield and then pull only the first record.

mattglet

3:03 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Select TOP 1 from database where status = 'notProcessed'

Easy_Coder

3:16 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in addition to TOP you also have this option...

set rowcount 1
select FIRST from database where status = 'notProcessed'
set rowcount 0

too much information

4:28 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for all of the help!

Turns out to be:

Select TOP 1 * from database where status = 'notProcessed'