A
Anonymous
Guest
How would be the best way to fetch the last row in a MySQL table?
$inserted_id = mysql_insert_id($query_result);
That would depend on how your table is sorted too! Just select one row and sort the 'sort' column in descending order!Xerpher said:How would be the best way to fetch the last row in a MySQL table?
DoppyNL said:.....
mysql doesn't sort the table by itself, so getting the last record from it is almost completely random.
Greetz Daan
serge said:DoppyNL said:.....
mysql doesn't sort the table by itself, so getting the last record from it is almost completely random.
Greetz Daan
8) if there is no "ORDER" condition in query, mysql returns recordset in order it stored in database.
:twisted: But it is order as records stored in database!DoppyNL said:serge said:DoppyNL said:.....
mysql doesn't sort the table by itself, so getting the last record from it is almost completely random.
Greetz Daan
8) if there is no "ORDER" condition in query, mysql returns recordset in order it stored in database.
mysql DOES NOT return the recordset the way it was entered in the database!!!!
when you haven't deleted any records you may get what you expect, but when you deleted some rows and/or are working with records of a variable length and insert some after that you WILL get some other order wich is NOT the order you entered the records!!
Greetz Daan
------------------------How would be the best way to fetch the last row in a MySQL table?
That's true, but you don't know what order that isserge said::twisted: But it is order as records stored in database!