Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sql query

 
manish gupta
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try "SELECT * FROM table LIMIT 1;"
[ June 13, 2007: Message edited by: Chad Clites ]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic