I have a table named attribute:
id attributeid type
1 8 2
2 8 1
3 4 1
So how can I select attributeid that have both types of 2 and 1. In this case, only attribute 8 is qualified that.
select attributeid
from attribute
where type in (1,2)
This doesn’t produce the results I want, as it returns 4,8 which is wrong.
Thanks.
You can use something like this:
See SQL Fiddle with demo