• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Want 27 records (3 customers * 9 age groups)

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to select age group data separated by product
I have 3 products´╝î9 age groups
want 27 results
using MariaDB


this only gets 9

AgeGroup
AgeGroupID AgeGroupName

Customer
CustomerID AgeGroupID

Orders
OrderID CustomerID

OrderDetails
OrderDetailID OrderID ProductID

Products
ProductID
Thanks
 
K. Tsang
Bartender
Posts: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use inner join not left join.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inner join would never give more results than a left or right outer join. What I think is required here is a cross join. That will take all records from the left table (3) and combine them all with all records from the right table (9). The result would be the intended 3 * 9 = 27 records.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic