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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i want to get less row by SQL select statement

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all

My Sql select statement is giving 10 rows of data.
If i want to have only first three

then can "i have a refined SELECT statement which will only give 3 rows of data."

One alternative is get 10 rows and then pick up first 3.
But i don't want to do it.
 
If your on Oracle you could stick

and rownum < 4

to the end of your where condition(s)

 
Alternatively, before you use the select statement, you can use

SET ROWCOUNT 3

This will then only return 3 rows. Remember to use a

SET ROWCOUNT 0 command afterwards though, otherwise all your DML will only process 3 rows
 
Hi Mike and Tim
I tried Both ROWNUM and ROWCOUNT
but it doesn't work as i am Using MySQL.

Version is 9.33 and distibution is 3.22.25 for gnu linux

Well,It might works only in Oracle.

Thanks for responding me.

I look forward with the same kind of response from you pepole.
Thanks Again.
 
This issue was discussed in thread186-53754. Check it out for the right syntax.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top