【问题标题】:Inserting data from one column from one table to another specific table column while ignoring duplicates将数据从一个表的一列插入到另一个特定的表列,同时忽略重复项
【发布时间】:2011-01-18 00:42:51
【问题描述】:

我想将 table1 中的 column1 插入 table2 中的 column1。如果 table2 中 column1 的值已经存在,我不希望它插入它。

不过,我在这里发现了一个类似的问题,但所有表的列/行都不是一个,而且除了 column1 之外,两个表都有不同的架构。正因为如此,我认为这个问题仍然可以为像我这样的 mysql 新手提供更具体的答案。

【问题讨论】:

    标签: mysql


    【解决方案1】:
    Insert Table2( Column1 )
    Select Column1
    From Table1 As T1
    Where Not Exists    (
                        Select 1
                        From Table2 As T2
                        Where T2.Column1 = T1.Column1
                        )
    

    【讨论】:

      猜你喜欢
      • 2012-02-10
      • 1970-01-01
      • 2012-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多