Say you have a table:
`item`
With fields:
`id` VARCHAR( 36 ) NOT NULL ,`order` BIGINT UNSIGNED NOT NULL
and
Unique(`id`)
And you call:
INSERT INTO `item` ( `item`.`id`,`item`.`order` ) SELECT uuid(), `item`.`order`+1
MySql inserts the same uuid in all newly created rows.
So, if you start with:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, 0 bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb, 1
As a result, you will receive:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, 0 bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb, 1 cccccccc-cccc-cccc-cccc-cccccccccccc, 1 cccccccc-cccc-cccc-cccc-cccccccccccc, 2
How do I configure MySql to create another uuid foreach string?
I know that in MSSQL it works as expected:
INSERT INTO item ( id,[order] ) SELECT newid(), [order]+1
nb I know that I could select the results, skip them and issue a separate INSERT command for each line from my PHP code, but I don't want to do this. I want the work to be done on the database server where it was supposed to be done.
source share