copy column from one table to another

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

copy column from one table to another

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You didn't read far enough into the documentation... :P
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”.
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the old fashioned way... select then update.
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

thanks
Post Reply