how to copy a data from a table to anotehr table?
Posted: Sat Apr 05, 2003 11:52 pm
well this is if im not mistaken to copy the whole data in a table to another table
INSERT into destination_table SELECT * from source_table;
but how about if i want to copy a data from table a to table b?
let say that we know the username and we want to copy his real name to another table.....
well i got this one but it wont work.
$sql = "UPDATE details,mn SET details.name=mn.name, where details.idnum=mn.idnum";
$result=mysql_query($sql) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
it gives out an error
Died inserting login info into db. Error returned if any: You have an error in your SQL syntax near 'mn SET details.name=mn.name, where details.matric=mn.matric' at line 1
anyone?..
INSERT into destination_table SELECT * from source_table;
but how about if i want to copy a data from table a to table b?
let say that we know the username and we want to copy his real name to another table.....
well i got this one but it wont work.
$sql = "UPDATE details,mn SET details.name=mn.name, where details.idnum=mn.idnum";
$result=mysql_query($sql) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
it gives out an error
Died inserting login info into db. Error returned if any: You have an error in your SQL syntax near 'mn SET details.name=mn.name, where details.matric=mn.matric' at line 1
anyone?..