I need to pass data from one table to another, with previous help from this community, I get something like:
INSERT INTO newDatabase.newTable(name, description) SELECT old_name FROM oldDatabase.oldTable WHERE old_id > 2;
This works perfectly.
Now, the point is, not only to insert data from the old table but, as well, populate (is this the correct term?) specific table columns with random data.
However, this random data on those table columns, should be different on each new row created.
I believe something like this will take care of the random part:
$randomValue = mb_substr(md5(uniqid()), 0, 8);
And I was hopping that something like this could take care of the job:
INSERT INTO newDatabase.newTable(name, description) VALUES ((SELECT old_name FROM oldDatabase.oldTable WHERE old_id > 2), $randomValue;
1) I'm getting a query error: "1242 - Subquery returns more then 1 row".
2) I'm not aware of the php logic that will allow me to have different randomValue values, each time new rows are inserted.
Can I have your help please?
Thanks in advance,