Skip to content
Advertisement

SQL WHERE look for 2 data in one column

I got 2 tables

item:

part:

I wish to make a query to find what item is linked with name_part = ‘a’ AND name_part = ‘b’

2 different parts in a same item

Query:

The output us ‘0’

Maybe with nested WHERE ?

I’ve tried, but I can’t find how to make it work.

PS: I’ve already ask for a similar question but it’s was very imprecise.

Advertisement

Answer

Forpas’s solutions are very reasonable. This answer, though, extends your attempt.

You can do what you want with joins, but you need two of them:

Your version cannot work, because name_part cannot be both 'a' and 'b' in the same row.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement