[ANSWERED] Customer must own all 3 products
@Sergeant wrote: Hello, I'm looking for a query that select all clientIDs that have ordered for example all 3 products. Products: Table productsIDName Order Table ordersIDclientIDaddress etc. Order...
View Article[ANSWERED] Customer must own all 3 products
@DaveMaxwell wrote: You would need to do three separate sub selects and join them in SELECT C.Name FROM Client C JOIN (SELECT O.ClientID FROM Orders O JOIN Order_Lines L ON O.ID = L.OrderID JOIN...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: This isn't it I'm afraid, although I'm not sure what is, this doesn't give me all clientIDs and selecting by name in a WHERE clause is obviously not the way to go. This query selects...
View Article[ANSWERED] Customer must own all 3 products
@molona wrote: It is just a matter of interpretation. What @davemaxwell did was to get the list of clients that bought those three items (AND instead of OR). Your query is fine. There is more than one...
View Article[ANSWERED] Customer must own all 3 products
@DaveMaxwell wrote: Sergeant: This isn't it I'm afraid, although I'm not sure what is, this doesn't give me all clientIDs OK, short of typos, what I gave you worked EXACTLY as you asked. It provided...
View Article[ANSWERED] Customer must own all 3 products
@oddz wrote: The trick is using where with having to match only clients with the given number of products. In this case 3. SELECT o.clientID FROM orders o INNER JOIN orders_lines i ON o.ID = i.orderID...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: May I ask why shortening all those table names is so common? It's just a sidequestion but it makes it unnecesary difficult to clearly read the query in my opinion. Oddz, i like your...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: Oh and you don't select by productname because you have an ID to work with? It was just asample table structure. Read full topic
View Article[ANSWERED] Customer must own all 3 products
@DaveMaxwell wrote: Sergeant: May I ask why shortening all those table names is so common? It's just a sidequestion but it makes it unnecesary difficult to clearly read the query in my opinion. It's...
View Article[ANSWERED] Customer must own all 3 products
@molona wrote: Sergeant: May I ask why shortening all those table names is so common? Giving aliases help you to write faster, especially when you use a black screen which is quite common for most...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: Thank you oddz! You just made my day with your super easy to understand query which works like a charm! Kudos! Read full topic
View Article[ANSWERED] Customer must own all 3 products
@r937 wrote: DaveMaxwell: Note: You need to add DISTINCT to the select to get rid of duplicates. a clear sign of an inefficient, clumsy query -- it may produce the right results with DISTINCT added,...
View Article[ANSWERED] Customer must own all 3 products
@system wrote: This topic was automatically closed 91 days after the last reply. New replies are no longer allowed. Read full topic
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: Hello, I'm looking for a query that select all clientIDs that have ordered for example all 3 products. Products: Table productsIDName Order Table ordersIDclientIDaddress etc. Order...
View Article[ANSWERED] Customer must own all 3 products
@DaveMaxwell wrote: You would need to do three separate sub selects and join them in SELECT C.Name FROM Client C JOIN (SELECT O.ClientID FROM Orders O JOIN Order_Lines L ON O.ID = L.OrderID JOIN...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: This isn't it I'm afraid, although I'm not sure what is, this doesn't give me all clientIDs and selecting by name in a WHERE clause is obviously not the way to go. This query selects...
View Article[ANSWERED] Customer must own all 3 products
@molona wrote: It is just a matter of interpretation. What @davemaxwell did was to get the list of clients that bought those three items (AND instead of OR). Your query is fine. There is more than one...
View Article[ANSWERED] Customer must own all 3 products
@DaveMaxwell wrote: Sergeant: This isn't it I'm afraid, although I'm not sure what is, this doesn't give me all clientIDs OK, short of typos, what I gave you worked EXACTLY as you asked. It provided...
View Article[ANSWERED] Customer must own all 3 products
@oddz wrote: The trick is using where with having to match only clients with the given number of products. In this case 3. SELECT o.clientID FROM orders o INNER JOIN orders_lines i ON o.ID = i.orderID...
View Article[ANSWERED] Customer must own all 3 products
@Sergeant wrote: May I ask why shortening all those table names is so common? It's just a sidequestion but it makes it unnecesary difficult to clearly read the query in my opinion. Oddz, i like your...
View Article
More Pages to Explore .....