i use this code
update
contracts a,
contracts_history b
set
a.name_surname=b.name_surname
My table has 64 columns and I am looking for a solution to copy all data with out having to specify column names – along these lines:
$sql = "INSERT INTO `contracts_history`
SELECT * FROM `contracts` WHERE id='$contract_id'";
You can use the
insert into select...syntax as long as your tables are exactly the same number of fields with matching datatypes – otherwise you will have to use column names to specify what you want to copy.I just ran the following as an example for you to show you the syntax: