sql集合运算

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cxzhq2002/article/details/2080357

SELECT [autoid]
      ,[airCompanyCode]
      ,[resBookDesigCode]
      ,[discountRate]
      ,[createTime]
      ,[lastUpdateTime]
      ,[Route_limit]
      ,[line_limit]
      ,[days_limit]
      ,[TRVDATE_begin]
      ,[TRVDATE_end]
  FROM [supermarket].[dbo].[air_discount]
WHERE airCompanyCode='CA'
AND (discountRate<='70' OR route_limit IS NULL)

SELECT * FROM (SELECT [autoid]
      ,[airCompanyCode]
      ,[resBookDesigCode]
      ,[discountRate]
      ,[createTime]
      ,[lastUpdateTime]
      ,[Route_limit]
      ,[line_limit]
      ,[days_limit]
      ,[TRVDATE_begin]
      ,[TRVDATE_end]
  FROM [supermarket].[dbo].[air_discount]
WHERE airCompanyCode='CA') A
WHERE (discountRate<='70' OR route_limit IS NULL)

A&(B|C)=(A&B)|(A&C)


SELECT [autoid]
      ,[airCompanyCode]
      ,[resBookDesigCode]
      ,[discountRate]
      ,[createTime]
      ,[lastUpdateTime]
      ,[Route_limit]
      ,[line_limit]
      ,[days_limit]
      ,[TRVDATE_begin]
      ,[TRVDATE_end]
  FROM [supermarket].[dbo].[air_discount]
WHERE airCompanyCode='CA'
AND discountRate<='70' OR route_limit IS NULL

A&(B|C)=(A&B)|(A&C)
A&B|C!=(A&B)|(A&C)故其查讯结果不同 

展开阅读全文

没有更多推荐了,返回首页