Jump to content


MySQL to Select the smalled value


1 reply to this topic

#1 CoryMathews

    P2L Jedi

  • Members
  • PipPipPip
  • 554 posts
  • Gender:Male
  • Location:Texas

Posted 18 November 2007 - 06:40 PM

I know it can be done cause they taught me this in my db class i took a while back. i just dont remember it.

I am wanting to select from my table the row with the lowest id value. I dont want to do any fancy php crap or anything like that just sql. This way i can store it into a var and delete it. Tried googling this but only found about a thousand results all with the exact same basic select statement.

#2 dotbart

    Young Padawan

  • Members
  • Pip
  • 141 posts
  • Gender:Male
  • Location:Diepenbeek
  • Interests:Webdesign, Webdeveloppement, DJ, ...

Posted 18 November 2007 - 08:52 PM

you should use subquery's
SELECT * FROM my_table where id = (SELECT MIN(id) as lowest_id from my_table)

Edited by dotbart, 18 November 2007 - 08:53 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users