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'

Link to comment
Share on other sites

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

Edited by alena1347
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.