jd2007 Posted July 22, 2007 Share Posted July 22, 2007 +----+-----------------+--------+-----------+-----------------+-------+ | id | name | worked | notworked | link | romno | +----+-----------------+--------+-----------+-----------------+-------+ | 1 | A Sim | 0 | 0 | asim.exe | 1 | | 2 | Truck Sim | 1 | 0 | trucksim.exe | 2 | | 4 | Top Gun | 1 | 0 | topgun.exe | 3 | | 8 | BBBBBBBBBBBBBBB | 0 | 0 | BBBBBBBBBBBBBBB | 0 | | 7 | USA Tank Sim | 0 | 0 | tanksim.exe | 5 | +----+-----------------+--------+-----------+-----------------+-------+ the highest value in id is 8, how do i select this number ? Link to comment https://forums.phpfreaks.com/topic/61213-how-do-i-take-the-highest-value-in-the-id-column-from-a-mysql-table/ Share on other sites More sharing options...
redarrow Posted July 22, 2007 Share Posted July 22, 2007 that wont work as the id is incremented each time data is inputed but if insest use max(id) Link to comment https://forums.phpfreaks.com/topic/61213-how-do-i-take-the-highest-value-in-the-id-column-from-a-mysql-table/#findComment-304558 Share on other sites More sharing options...
Barand Posted July 22, 2007 Share Posted July 22, 2007 If you are inserting a new record and need the latest id to insert related record/s in another table then the safest way is to call $newid = mysql_insert_id(); immediately after the insert and use that value to insert in other table. Link to comment https://forums.phpfreaks.com/topic/61213-how-do-i-take-the-highest-value-in-the-id-column-from-a-mysql-table/#findComment-304571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.