Reputation: 79
I am trying to use upsert to update and or insert from another table
INSERT INTO table1 (
`uniqueCol1`,
`uniqueCol2`,
`created`,
`dataCol`
)
VALUES (
1,
t1.uniqueCol2Value,
NOW(),
t1.dataColValue
)
ON DUPLICATE KEY UPDATE
`dataCol` = t1.dataColValue
Now from what I can tell I don't see how I can add what I think should be FROM table2 t1
into this to grab the values and put them into table1
Upvotes: 0
Views: 232
Reputation: 571
I would suggest:
INSERT INTO table1 (
`uniqueCol1`,
`uniqueCol2`,
`created`,
`dataCol`
)
SELECT 1, uniqueCol2Value, NOW(), dataColValue FROM table2
Upvotes: 1