22 Jan
2013
22 Jan
'13
10:26 a.m.
CREATE TEMPORARY TABLE tmp SELECT * FROM myTable WHERE cat_uid=10; UPDATE tmp SET cat_uid=11; INSERT INTO myTable SELECT * FROM tmp;
Well, you could cut that down to simply ... INSERT INTO myTable (cat_id, col1, col2, col3) SELECT 11, col1, col2, col3 FROM myTable WHERE cat_uid = 10; By not specifying the uid in the INSERT statement it allows MySQL to generate one. And you're bypassing the temporary table, so it's probably at least twice as fast.