RE: [PHP] Querying for MAX

From: Date: Wed, 12 Jun 2002 23:36:23 +0000
Subject: RE: [PHP] Querying for MAX
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-101835@lists.php.net to get a copy of this message
> What I’m trying to do here is not inside PHP nor MySQL books > I have. I need to query the DB to look the max result in a > column. That is, if I have affiliate members with ID going > from 1 to 10, get the query to know that the last member > added was 10 so I can add member 11 without using > auto_increment, because I need to insert old members too > which already have ID numbers. Is that possible? This is really a mysql question rather than a php question and would probably be more appropriate to a mysql list. In any event, if you seriously think auto_increment is not your solution here you probably need to rethink your database design. This is exactly what auto_increment is for. If someone is already in the list then you can get their ID with a select and then do an update on their row, if someone doesn't exist then you add them and ID auto_increments in the process. -- ---------------------------------------------------------------------- Outback Queensland Internet ************************ Longreach ** New Web Site Online * Queensland ************************ Australia W: www.outbackqld.net.au

« previous php.general (#101835) next »