File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Sql query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Sql query" Watch "Sql query" New topic
Author

Sql query

manish gupta
Ranch Hand

Joined: Nov 06, 2005
Posts: 36
Hi ,

I want to know the query to get the first record of table

like select first recorf from "table" orderby

Please help me in this.

Thanks with regard
Manish
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
Try "SELECT * FROM table LIMIT 1;"
[ June 13, 2007: Message edited by: Chad Clites ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
Note that SQL has no notion of an implicit ordering of records, so there is no designated "first record". The "LIMIT 1" technique will ensure that you'll get back exactly one record, but it could be a different one every time you call it. To make sure you get the desired record, sort the results so that the record you're looking for is indeed at the top, something like "SELECT * FROM table ORDER BY my_criterium LIMIT 1".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sql query