如何在SQL中使用类似XOR的函数

我似乎无法掌握满足我对这个问题的需求所需的sql。 我到目前为止:
select * from customformresponses
INNER JOIN exhibitors ON
Exhibitors.ExhibitorId= customformresponses.ExhibitorId
WHERE customformresponses.exhibitorid='8179cde9-b922-430a-9024-bd4cb8b3d05c'
  and exhibitors.exhibitionID = 'e641a3d4-cb57-4f67-86a1-5c2f4c3cf6e0'
  and customformresponses.FormID = 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26' 
我需要在3个不同的formID值中搜索响应,但我遇到的问题是,如果我有:
customformresponses.FormID = 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26'  or
customformresponses.FormID = 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26' or
customformresponses.FormID = 'e69cee39-2519-434d-be3e-516ba156b444'
然后它只返回第一个真实条件的结果而不是任何真实条件。 如何从符合此条件的行返回所有结果?     
已邀请:
我想这就是你所追求的
select *
from customformresponses
INNER JOIN exhibitors
    ON Exhibitors.ExhibitorId= customformresponses.ExhibitorId
WHERE customformresponses.exhibitorid='8179cde9-b922-430a-9024-bd4cb8b3d05c'
AND exhibitors.exhibitionID = 'e641a3d4-cb57-4f67-86a1-5c2f4c3cf6e0'
AND
( customformresponses.FormID = 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26'
  OR
  customformresponses.FormID = 'e69cee39-2519-434d-be3e-516ba156b444')
它需要匹配的Exhibitorid和exhibitionid,但对于FormID,它将匹配任何两个。 所以,如果你有两行
exhibitorid      | exhibitionid     | formid
8179cde9-b922... | c7f5f0de-35f8... | c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26
8179cde9-b922... | c7f5f0de-35f8... | e69cee39-2519-434d-be3e-516ba156b444
它们都将在输出结果集中     
如果只是为了避免重复GUID和列名...
SELECT *
FROM customformresponses
  INNER JOIN exhibitors ON Exhibitors.ExhibitorId = customformresponses.ExhibitorId
WHERE (
  CASE customformresponses.exhibitorid WHEN '8179cde9-b922-430a-9024-bd4cb8b3d05c' THEN 1 ELSE 0 END +
  CASE exhibitors.exhibitionID WHEN 'e641a3d4-cb57-4f67-86a1-5c2f4c3cf6e0' THEN 1 ELSE 0 END +
  CASE customformresponses.FormID WHEN 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26' THEN 1 ELSE 0 END
) = 1
    
select * from customformresponses 
INNER JOIN exhibitors     
ON Exhibitors.ExhibitorId= customformresponses.ExhibitorId 
WHERE customformresponses.exhibitorid='8179cde9-b922-430a-9024-bd4cb8b3d05c' 
AND exhibitors.exhibitionID = 'e641a3d4-cb57-4f67-86a1-5c2f4c3cf6e0' 
AND ormresponses.FormID IN  ( 'c7f5f0de-35f8-412d-9c91-eaf8bb1a3c26', 'e69cee39-2519-434d-be3e-516ba156b444') 
    

要回复问题请先登录注册