re: How to write this SQL select the best way? VIEW POST

VIEW FULL DISCUSSION
 
select bom_id
from line
where item_id = 'KetchupBottle' or item_id = 'RubberDuckey'
group by bom_id
having count(*) = 2;

The having clause needs to check that the count equals the number of item ids you're matching.

 

Hey Dian thanks for that suggestion! The having was what I've been missing, worked out very well, thanks a lot! 😊

It's those kinda tasks where I can learn a lot from.

code of conduct - report abuse