在查询中包含一行

问题描述:

我有这个简单的视图调用D_View。我试图只选择没有销售状态的物品。我也只想选择一个苹果是否有销售状态。 我怎么能在1个查询中做到这一点?在查询中包含一行

Select * from D_View where SALE in (''); 
Select * from D-View where FRUIT in ('Apple'); 

我的尝试是:

Select * from D_View where SALE in ('') and FRUIT in ('Apple'); 

但这只会给我苹果没有销售情况。

+0

原因downvote请,让我可以学习未来的问题? – Brad

使用or

Select * 
from D_View 
where SALE in ('') 
or FRUIT in ('Apple'); 

你有2个条件。他们需要经营OR。 原因是你要么与任何状态的苹果OR谁没有销售状态的项目。

查询:

Select * 
from D_View 
where 
SALE in ('') or FRUIT in ('Apple'); 

Select * from D_View where SALE in ('') or FRUIT in ('Apple');