Page 1 of 1
please how to find last row
Posted: Sat Jul 24, 2004 8:47 am
by lazerbri
I can find the Id number of last entry with
$iD=mysql_insert_id();
but need to get the last number with out adding any new record
Its prob very easy but I can't find it can you help
thanks brian
Posted: Sat Jul 24, 2004 9:27 am
by Weirdan
Code: Select all
select max(`name_of_the_field`) from `name_of_the_table`;
thank you so much
Posted: Sat Jul 24, 2004 9:41 am
by lazerbri
thanks for the fast responce it works I could'nt move ahead with out it
Posted: Sat Jul 24, 2004 4:43 pm
by tim
why not simple
$sql = "SELECT * FROM table_name ORDER by DESC LIMIT 1";
thanks this looks good to
Posted: Sun Jul 25, 2004 7:19 am
by lazerbri
I will try using this but con't quit under stand what DESC LIMIT 1 is
but will look on google to learn about it thanks
Posted: Sun Jul 25, 2004 11:37 am
by feyd
he meant:
Code: Select all
SELECT * FROM `table_name` ORDER BY `some_field` DESC LIMIT 1
...sort by 'some_field' in descending order.
Posted: Sun Jul 25, 2004 1:22 pm
by tim
oops
thanks for clarifying that feyd.
