SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Display first X rows with SQL
-
Nov 8, 2001, 19:51 #1
- Join Date
- Feb 2000
- Location
- Brisbane, Queensland, Australia
- Posts
- 187
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Display first X rows with SQL
Hi, I am having a problem with an SQL query and a friend has a book of mine I know has the answer. So I decided to ask here instead.
I am using JSP with an Access database and need to make an SQL query which returns the first four results in a resultset.
I know I could just get all the results, and only take the first four results from the set, but I figured it is more efficient if I use an SQL query which only returns the first four results.
The query which returns everything is
SELECT *
FROM TableName
ORDER BY FieldName desc;
Would be great if someone could help me with the count function or whatever to only return the first four results from the above query.
Thanks
-
Nov 8, 2001, 19:56 #2
Hi Wilmot,
Try something like this:
SELECT TOP 4 tableItem
FROM tableNAME
ORDER by tblItem desc
Hope that helps
Charles
Bookmarks