在选择查询中选择多行

时间:2019-03-26 14:03:11

标签: oracle

嗨,我正在尝试在where子句的select查询中选择多个列。当我尝试独立运行查询时,它可以工作,但是当我将其与“ and”连接时,它不起作用。现在,它当前拉0行。

 Select * from PA_FCS_price_segment
 WHERE MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012'
  and  MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013' ;

2 个答案:

答案 0 :(得分:3)

如果认为您是认真的

Select * from PA_FCS_price_segment
WHERE (MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012')
OR    (MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013');

因为MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012'MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013'是互斥的

答案 1 :(得分:3)

您可以将in条件用于多个值:

 select * from PA_FCS_price_segment
 WHERE MARKET_FROM ='FCS011' AND MARKET_TO in ('FCS012', 'FCS013')
  

in_condition是成员资格条件。它会在值列表或子查询中测试值的成员资格