选择基于两个列作为键的返回值

时间:2022-06-08 15:38:20

I have a problem that I can't seem to solve. What I am trying to do is find unique columns based in table A that doesn't exist in other table B and store them in table B. Something on the lines of

我有一个问题,我似乎解决不了。我要做的是找到表A中不存在的唯一列,并将它们存储在表B中

 SELECT DISTINCT(A.FNAME), A.LNAME from ADDRESS A WHERE NOT EXIST 
                              (SELECT DISTINCT(B.FNAME),B.LNAME
                               FROM ADDRESSLIVE B)

but that doesn't seem to work, my ideal logic is to use the FNAME column and LNAME column together as a unique id, since those columns separately can be duplicates. Can someone inform me of what I am doing wrong, or what I am trying to do if its even possible?

但这似乎行不通,我的理想逻辑是将FNAME列和LNAME列作为唯一id一起使用,因为这些列可以单独复制。有人能告诉我我做错了什么吗?如果可能的话,我想做什么?

1 个解决方案

#1


4  

 SELECT DISTINCT A.FName, A.LName FROM Address A
    WHERE NOT EXISTS 
      (SELECT * FROM AddressLive B WHERE B.FName = A.FName AND B.LName = A.LName)

#1


4  

 SELECT DISTINCT A.FName, A.LName FROM Address A
    WHERE NOT EXISTS 
      (SELECT * FROM AddressLive B WHERE B.FName = A.FName AND B.LName = A.LName)