Skip to content
Advertisement

SQL: Search two strings in the same column through subquery

I have three tables using an Oracle database:

The mix table interconnects Recipe and Ingredients. I am supposed to find the one cocktail made by the barman Otto which utilizes ingredients from Spain and Cuba. This is what I have tried until now:

Expected Output from this query:

At the moment, I am just getting all the cocktails made by the barman Otto without distinction of the ingredients, like:

Since I am new to SQL, I do not know how to build up a synchronized query which searches for two strings at the same time or for two records in the same field. That was by far my best attempt. Every hint would be really appreciated! Thank you very much in advance

Advertisement

Answer

With this query you will get all the cocktails that have ingredients from Cuba and Spain and ingredients for that cocktails can also be from other countries as long as one is from Cuba and one is from Spain.

DEMO

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