Jump to content

How do i take the highest value in the id column from a mysql table ?


jd2007

Recommended Posts

+----+-----------------+--------+-----------+-----------------+-------+

| 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 ?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.