Reputation: 121
Hi I am trying to select multiple columns in a select query in the where clause. When I try to run the query independently, it works but when I connect it with "and" it doesn't work. Right now it currently pulls 0 rows.
Select * from PA_FCS_price_segment
WHERE MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012'
and MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013' ;
Upvotes: 0
Views: 148
Reputation: 58774
You can use in condition for multiple values:
select * from PA_FCS_price_segment
WHERE MARKET_FROM ='FCS011' AND MARKET_TO in ('FCS012', 'FCS013')
An in_condition is a membership condition. It tests a value for membership in a list of values or subquery
Upvotes: 3
Reputation: 38179
If think you mean
Select * from PA_FCS_price_segment
WHERE (MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012')
OR (MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013');
since MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS012'
and MARKET_FROM ='FCS011' AND MARKET_TO = 'FCS013'
are mutually exclusive
Upvotes: 3