Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Transfer Copy Row to Another Table


ocon - 5:06 am on Aug 16, 2012 (gmt 0)


I have a database with many columns that I would like to copy whole rows from to insert into a second table.

The structures between the two tables are the exact same.

I'd like to avoid having to specify every column name and column value.

I've adapted this code from other forum posts, but I can't get it to work for me. Am I doing something wrong?

$mysql_connect = mysql_connect(...);
mysql_select_db(...);
mysql_set_charset(...);

mysql_query("INSERT INTO table2 (SELECT * FROM table1 WHERE name = '".$name."' LIMIT 1)");

mysql_close($mysql_connect);


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4485307.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com