Hello there. This might be an obvious question, but still I don't know the answer. How do I duplicate a MySQL row. Any Query i could write? Something like: DUPLICATE WHERE ID = 'X' Would be nice if I could UPDATE too. Changing some values between them. Thanks in advance.
Let's say you had the following table[sql] colA|colB|colC 2 | 7 | 9 | 3 | 8 | 6 | 1 | 8 | 7 | [/sql] and you needed insert a duplicate of the row starting which has a 1 in colA, you could do it like this: INSERT INTO tbl(colA,colB,colC) select * from tbl where colA='1'; BUT, you would have to make sure your database does allow duplicates, and think about turning autocommit off and back on after.
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] {VALUES | VALUE} ({expr | DEFAULT},...),(...),... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ] pls try this...