i have a table field type varchar(36) and i want to generate it dynamically by mysql so i used this code:
$sql_code = 'insert into table1 (id, text) values (uuid(),'some text');';
mysql_query($sql_code);
how can i retrieve the generated uuid immediately after inserting the record ?
Its pretty easy actually you can pass this to mysql and it will return the inserted id.
set @id=UUID();
insert into <table>(<col1>,<col2>) values (@id,'another value');
select @id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With