Page 1 of 1
copy column from one table to another
Posted: Sun Aug 14, 2005 5:51 pm
by dsdsdsdsd
hello; I am using my webhost's PHPMyAdmin console;
update table_A set col_1 = ( select col_1 from table_B ) // does not work
update table_A set col_1 = table_B.col_1 where ( table_A.col_# = table_B.col_# ) // does not work
any thoughts
thanks
dsdsdsdsd
Posted: Sun Aug 14, 2005 7:17 pm
by feyd
Posted: Sun Aug 14, 2005 7:21 pm
by dsdsdsdsd
hello;
I have managed to get:
Code: Select all
update table_A , table_B set table_B.col_1 = table_A.col_1 where table_B.col_# = table_A.col_#
to work on PHPMyAdmin 2.6.1-pl3 with MYSQL 4.0.16
but it will not work on PHPMyAdmin 2.6.0-pl3 with MYSQL 3.23.58;
any thoughts
thanks
Shannon Burnett
Asheville NC USA
Posted: Sun Aug 14, 2005 7:27 pm
by feyd
You didn't read far enough into the documentation...
UPDATE wrote: Starting with MySQL 4.0.4, you can also perform UPDATE operations that cover multiple tables. The table_references part lists the tables involved in the join. Its syntax is described in Section 13.2.7.1, “JOIN Syntax”.
Posted: Sun Aug 14, 2005 9:39 pm
by dsdsdsdsd
hello feyd;
until tonight I did not know what versions of MYSQL I was using so frankly I had never given any thought to the verion-related notes in the MYSQL documentation;
so any ideas on copying a column from one table to another with MYSQL 3.23.58;
thanks
Shannon Burnett
Asheville NC USA
Posted: Sun Aug 14, 2005 10:13 pm
by feyd
the old fashioned way... select then update.
Posted: Mon Aug 15, 2005 4:06 pm
by dsdsdsdsd
thanks