Nat*_*era 54
有一个按位XOR运算符 - 插入符号(^),即用于:
SELECT 170 ^ 75
Run Code Online (Sandbox Code Playgroud)
结果是225.
对于逻辑XOR,使用ANY关键字而不是ALL,即
WHERE 5 > ANY (SELECT foo) AND NOT (5 > ALL (SELECT foo))
Run Code Online (Sandbox Code Playgroud)
Alb*_*aro 36
使用布尔代数,很容易证明:
A xor B = (not A and B) or (A and not B)
A B | f = notA and B | g = A and notB | f or g | A xor B
----+----------------+----------------+--------+--------
0 0 | 0 | 0 | 0 | 0
0 1 | 1 | 0 | 1 | 1
1 0 | 0 | 1 | 1 | 1
1 1 | 0 | 0 | 0 | 0
Run Code Online (Sandbox Code Playgroud)
Sha*_*vac 17
正如你在评论中所阐明的那样,你说了一个例子:WHERE(注意为空)^(ID为空).我不明白为什么你选择接受这里给出的任何答案来回答这个问题.如果我需要一个xor,我想我必须使用AND/OR等效逻辑:
WHERE (Note is null and ID is not null) OR (Note is not null and ID is null)
Run Code Online (Sandbox Code Playgroud)
这相当于:
WHERE (Note is null) XOR (ID is null)
Run Code Online (Sandbox Code Playgroud)
当'XOR'不可用时.
was*_*was 15
MS SQL只是简短形式(自SQL Server 2012以来):
1=iif( a=b ,1,0)^iif( c=d ,1,0)
Run Code Online (Sandbox Code Playgroud)