RE: [PHP] finding the highest primary key in a table
| From: | Martin Towell | Date: | Tue, 25 Jun 2002 00:57:08 +0000 |
| Subject: | RE: [PHP] finding the highest primary key in a table | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-103707@lists.php.net to get a copy of this message | ||
$query = "SELECT max(id) FROM table";
-----Original Message-----
From: Phil Schwarzmann [mailto:pschwar@jhmi.edu]
Sent: Tuesday, June 25, 2002 10:54 AM
To: php-general@lists.php.net
Subject: [PHP] finding the highest primary key in a table
I want to find the number of the highest primary key in a particular
MySQL table.
I could do something like...
$query = "SELECT id FROM table";
...then run the query, then create a loop and check all the ID's
(primary key) for the highest...
...but that seems like way too much.
Any ideas ??