dimanche 25 octobre 2015

SQLite select specific product and the rest ordered

I have an issue. Suppose i have the table in Northwind database, where there are orders placed containing some products.

Order | Product
1 | Milk
1 | Cacao
1 | Juice
2 | Milk
2 | LemonJuice
2 | OrangeJuice
3 | Lemonade
3 | Remoulade
3 | GrapefruitJuice

Suppose Order is being placed and it contains FX Order 1 Milk, Cacao, Juice. Order 2 has Milk, LemonJuice, OrangeJuice. I need to select all the orders which contains Milk ordered and to select the rest what have they ordered, SO If person in order 1 has ordered Milk, then i need to take cacao and juice as well. The same in order 2, I see Milk ordered, then i need to take LemonJuice and OrangeJuice, Whereas Order 3 does not contain Milk, So I do not need it. How can i do that? Trying for the second day, I am really in doubt of how to write it..

Aucun commentaire:

Enregistrer un commentaire