mysql - Get combined data from table -
i have folling problem didn't solved days.
i have 3 tables.
table "distributor"
id | distributor 1 | distributor 2 | distributor b 3 | distributor c table "product":
id | product 1 | apple 2 | peache 3 | banana 4 | lemon table "distributorproduct" - distributor can deliver product.
id | distributorid | productid 1 | 1 | 1 2 | 1 | 2 3 | 1 | 3 4 | 1 | 4 5 | 2 | 1 6 | 2 | 3 7 | 2 | 4 7 | 3 | 3 7 | 4 | 4 now want distributors can deliver apple , banana. (the result must distributor , distributor b).
how can this? sql-statement?
thanks lot help.
dieter
this should work:
select distributor.id, distributor.name distributor, product apple, product banana, distributorproduct distributorproduct.distributorid = distributor.id , distributorproduct.productid = apple.id , apple.name = 'apple' , distributorproduct.productid = banana.id , banana.name = 'banana' group distributor.id
Comments
Post a Comment