在查询中包含一行
问题描述:
我有这个简单的视图调用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');
但这只会给我苹果没有销售情况。
答
使用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');
原因downvote请,让我可以学习未来的问题? – Brad