- Forums
- MYSQL
- How Select Last Row In A Database
If You Use Mysql For Your Php Script You Will Find This Short Tutorial Helpful Because It Hels You Selecting The Last Row In A Table [2307], Last Updated: Mon Jun 24, 2024
Webune Support
Mon Oct 19, 2009
0 Comments
439 Visits
hi, welcome to webune support forums. today we will teach you something very important when creating your php scripts using a MySQL database.
for example, lets say we want to get the last row in a MySQL database table, so how can we do this? easy.
for the purpose of this short tutorial, lets say i want to select the last user that signed up to our forums. this is how i would do it:
PHPCODE:
$query = "SELECT username from users ORDER BY user_id DESC LIMIT 0,1";
that will give you the LAST username in my users table
hope that helps.. REMEMBER, if you need quality PHP/MySQL web hosting, Webune is always here for you.
thanks
Webune Support Team