Reputation: 1785
Table 1 - leads
column 1 - lead_source_description
Table 2 - leads_cstm
column 2 -referrer_c
I am trying to copy values from table2.column2
to table1.column1
using the following query
INSERT INTO leads (`lead_source_description`)
SELECT `referrer__c`
FROM leads_cstm
I know it is quiet a simple task to do and has been asked already . But I am getting the following error.
#1062 - Duplicate entry '' for key 'PRIMARY'
Upvotes: 2
Views: 16951
Reputation: 816
INSERT INTO leads (`lead_source_description`)
SELECT DISTINCT `referrer__c` FROM leads_cstm
Upvotes: 1
Reputation: 3850
Your "leads" table must have a auto increment ID value and you need to insert like this:
INSERT INTO leads (SELECT NULL, table1.column1 , '', ....) // all the column of leads table shoudl be inserted
Upvotes: 0