SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Sql
-
May 21, 2004, 00:29 #1
- Join Date
- May 2004
- Location
- India
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sql
How do i limit the number of rows selected,
like if i want to select the top three sal takers in the emp table.
-
May 21, 2004, 00:57 #2
- Join Date
- May 2004
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can achieve this by sticking the LIMIT parameter to your SQL statement. This limits the number of results the SQL statement selects from the table(s) to a number you specificy. In your case, you would need to stick LIMIT 3 to your SQL statement.
In the example you mentioned, where you want to select the top 3 out of the column sal, which is in the table emp, this would result in the following SQL query:
Code:SELECT * from emp ORDER BY sal DESC LIMIT 3;
Bookmarks