我在下面的代码中返回了第一个表中没有的名称。我的问题是我需要在连接之前使用第一个表上的位置。
SELECT *
FROM Mock A
LEFT JOIN List B ON (A.Person = B.Name)
WHERE A.Person IS NULL OR B.Name IS NULL
UNION
SELECT *
FROM KyleMock A
RIGHT JOIN List B ON (A.Person = B.Name)
WHERE A.Person IS NULL OR B.Name IS NULL
第一张桌子需要做的是
SELECT * FROM A WHERE Style = 'Turtle'
我试过
WHERE (A.Person IS NULL OR B.Name IS NULL) AND Style = 'Turtle'
这只是将我的结果限制在Style ='Turtle'的位置,并且不包括其他行。
答案 0 :(得分:1)
您可以过滤掉连接条件本身的记录,例如:
SELECT *
FROM Mock A
LEFT JOIN List B ON (A.Person = B.Name AND A.Style = 'Turtle')
WHERE A.Person IS NULL OR B.Name IS NULL
UNION
SELECT *
FROM KyleMock A
RIGHT JOIN DraftList B ON (A.Person = B.Name)
WHERE A.Person IS NULL OR B.Name IS NULL