开发者

Inserting data from one column from one table to another specific table column while ignoring duplicates

I want to insert column1 from table1 to column1 in table2. If the value at column1 in table2 already exists I don't want it to insert it.

Though, I found a question on here that is similar but with all the table columns/rows in开发者_运维技巧stead of just one, plus both tables have different schemas except for column1. Because of this, I thought this question would still be valid to post for a more specific answer for mysql newbies like me.


Insert Table2( Column1 )
Select Column1
From Table1 As T1
Where Not Exists    (
                    Select 1
                    From Table2 As T2
                    Where T2.Column1 = T1.Column1
                    )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜