Example of three valued logic in SQL Server

后端 未结 5 1000
难免孤独
难免孤独 2020-12-16 05:02

I understand that SQL uses three valued logic but I am having trouble understanding how to use this in practice, especially why TRUE || NULL = True and FA

5条回答
  •  攒了一身酷
    2020-12-16 05:24

    An example of TRUE || NULL = True would be

    declare @x as int = null;
    if 1=1 or @x/1=1
        print 'true'
    

    An example of FALSE && NULL = False would be

    declare @x as int = null;
    if not(1=2 and @x/1=1)
        print 'false'
    

提交回复
热议问题