MYSQL_INSERT_ID's question
CREATE TABLE ' create_id ' (
' id ' int (ten) unsigned not NULL auto_increment COMMENT ' generate Auto-increment user_id ',
' V ' varchar (1) Not NULL COMMENT ' is used to generate a new ID ',
PRIMARY KEY (' id '),
UNIQUE KEY ' V ' (' V ')
) Engine=myisam DEFAULT Charset=utf8;
Replace into ' create_id ' set ' V ' = ' 1 ';
After executing this SQL, the Insert ID cannot be obtained with mysql_insert_id. What method/function can get the new ID generated by replace into?
------Solution--------------------
The replace directive may or may not produce a new ID
So it's normal to get it.
So what is the method/function that can get the new ID generated by replace into?
The answer is no, but you can specify the ID
------Solution--------------------
Select last_insert_id () as ' ID ' from ' create_id ';
With
Select id from ' create_id ' ORDER BY id DESC LIMIT 1
Isn't it the same?
------Solution--------------------
Reference:
Select last_insert_id () as ' ID ' from ' create_id ';
With
Select id from ' create_id ' ORDER BY id DESC LIMIT 1
Isn't it the same?
In case of concurrency, ORDER BY id DESC may be someone else's ID.
is last_insert_id () within the scope of a database connection?
------Solution--------------------
Originally this can also get ID, learn the
------Solution--------------------
Select ID from TB ORDER BY id DESC LIMIT 1
------Solution--------------------
Reference:
Select ID from TB ORDER BY id DESC LIMIT 1
This can only get the ID inside the library, right? The landlord is when inserting data, to get the current ID.
I used TP to write:
$Form =m (' member ');
$sql = "Show table status where Name= ' Fht_member '";
$rs = $Form->query ($sql);
$Mid = $rs [0][' auto_increment '];
The return recordset has a [' auto_increment '], which is the currently inserted self-increment ID