Jump to content

Copy value column from a table to other table


dani33l_87

Recommended Posts

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'

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.