On Sun, 26 Oct 2003 13:40:20 +0000, dan wrote:
> The MAX(id) didn't return anything [...]
Are you sure about that? Generally, MAX(id) _always_ returns something,
ie:
SELECT MAX(user_id) FROM user
This one will return the highest 'user_id' value, _or_ 0 if there are no
records in the 'user' table.
> SELECT id FROM memodata ORDER BY id DESC
Then you should also limit the expression, thus offloading the SQL server
a bit;
SELECT id FROM memodata ORDER BY id DESC LIMIT 1
> then take the first line value and ignore the rest.
With 'LIMIT' you don't need to worry about ignoring anything. Just ignore
ignoring. :-)
> Ideally though i want the last line with the highest id number.
If you want the last auto_increment value, you could always use the MySQL
proprietary 'mysql_insertid';
my $stInsert = $dbh->prepare( ... );
$stInsert->execute();
$stInsert->finish();
my $last_insert_id = $stInsert->{ 'mysql_insertid' };
> I know for a fact that another INSERT won't happen before the SELECT
> because they happen immediately one after the other.
Do yuo really? Is there _always_ only one user using the script?
--
Tore Aursand <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]