Computing.Net > Forums > Database > select only one row

select only one row

Reply to Message Icon

Original Message
Name: eye-designs
Date: May 8, 2007 at 04:44:59 Pacific
Subject: select only one row
OS: Win Vista Biz
CPU/Ram: Pentium M
Comment:

hello,
i've got a select query which returns a couple of rows.
now i would like for the query to return only one row (the first match it can find).
how do i do that?
thank you!


Report Offensive Message For Removal


Response Number 1
Name: sboffin
Date: May 8, 2007 at 11:13:51 Pacific
Reply: (edit)

try

SELECT
TOP 1
*
FROM TABLE



Report Offensive Follow Up For Removal

Response Number 2
Name: Don Arnett
Date: May 15, 2007 at 09:26:07 Pacific
Reply: (edit)

I've also seen the keyword "limit" used. The particular keyword and syntax will be particular to your database.



Report Offensive Follow Up For Removal

Response Number 3
Name: kevin freak
Date: August 3, 2007 at 06:00:33 Pacific
Reply: (edit)

Hi,
You can limit the number of rows in the output of a query by using the rowcount parameter as

sql > select * from emp where rowcount < 2;
hope it will help u :-)


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: select only one row

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge