Nov 1, 2018

MySQL example to duplicate a row in the same table

CREATE TEMPORARY TABLE tmp_contacts SELECT * FROM contacts WHERE contactid = 88;
UPDATE tmp_contacts SET contactid = NULL;
-- You may not need limit 1
INSERT INTO contacts SELECT * FROM tmp_contacts limit 1;
DROP TEMPORARY TABLE IF EXISTS tmp_contacts;
SELECT last_insert_id();