MySQL, Insert Select

Posted May 8th, 2005 in MySQL, PHP, Programming by Louie Miranda

I been working with a PHP function on how I can duplicate an entry on sql. My first approach was to use the while() function, but what it does was loop the entire process.

I posted at phpugph.com and ask them what they think, and they suggested the INSERT – SELECT of MySQL.

1
2
3
mysql> INSERT INTO jt_entry (uid,entry_requested_by,entry_status,entry_category,entry_title,entry_description)
select uid, entry_requested_by, entry_status, entry_category, entry_title, entry_description from jt_entry
where entry_id=3limit 1;

Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

Thanks!