Hello,
Some mysql join query problem.
I have two tables. product and material. There is many to many raltion. So I have created other table called products_to_materialcategories for mapping relationship.
Following are the rows.
p1 m1
p1 m2
p2 m3
p3 m2
p3 m4
Now I want to access product, and products_to_materialcategories and find out distinct products, without using distinct keyword, and in a single query.
Can anybody help me.
Query is like following but it do not gives me distinct products list. There are duplicate p3, as p3 is appearing twice in products_to_materialcategories table.
SELECT * FROM products_master a, products_to_materialcategories b WHERE a.products_master_id = b.products_master_id AND a.products_status = 1 AND ( b.materialcategories_id = 5 OR b.materialcategories_id = 3 ) ORDER BY a.products_sort_order