dani33l_87 Posted February 7, 2013 Share Posted February 7, 2013 Hi, How can I copy the value from a column (table nw_items) to other table (nw_products). or even better, into a column (in nw_products) that already exists and has all values set to 0 ? I tried this INSERT INTO nw_products (ID_PLAYER) SELECT nw_items.ID_OWNER FROM nw_items; and got this error :#1062 - Duplicate entry '0-0' for key 'PRIMARY' Link to comment https://forums.phpfreaks.com/topic/274135-copy-value-column-from-a-table-to-other-table/ Share on other sites More sharing options...
Barand Posted February 7, 2013 Share Posted February 7, 2013 Give us a clue. What is the structure of said tables and how are they related? Link to comment https://forums.phpfreaks.com/topic/274135-copy-value-column-from-a-table-to-other-table/#findComment-1410616 Share on other sites More sharing options...
alena1347 Posted February 7, 2013 Share Posted February 7, 2013 suppose you have two tables table1 and columnname1 as column and table2 with columnname2 as column then the query would look like UPDATE table1,table2 SET table1.columnname1=table2.columnname1 where table2.columnname1=something; the error is for inserting duplicate values in the column with primary key check for that Link to comment https://forums.phpfreaks.com/topic/274135-copy-value-column-from-a-table-to-other-table/#findComment-1410697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.