0

For following table data:

ID     | Property
=================
1      | Sweet
2      | Sweet
2      | Sour
3      | Hot

How can I get the ID's having Property Sweet AND Sour (in this example, 2)

Thanks.

1 Answer 1

0

The easiest way would be group by and having

select 
ID from table_name
where Property in('Sweet','Sour')
group by ID
having count(*)=2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.