T-SQL XOR Operator

后端 未结 9 661
既然无缘
既然无缘 2020-11-30 23:43

Is there an XOR operator or equivalent function in SQL Server (T-SQL)?

9条回答
  •  时光说笑
    2020-12-01 00:29

    There is a bitwise XOR operator - the caret (^), i.e. for:

    SELECT 170 ^ 75
    

    The result is 225.

    For logical XOR, use the ANY keyword and NOT ALL, i.e.

    WHERE 5 > ANY (SELECT foo) AND NOT (5 > ALL (SELECT foo))
    

提交回复
热议问题