开发者

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

开发者 https://www.devze.com 2023-02-05 09:01 出处:网络
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.

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

精彩评论

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