Guest User

Untitled

a guest
Aug 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. sql to build categories menu that have products
  2. select c1.*, c2.* from categories c1, categories c2, products_categories pc where c1.category_id = c2.parent_id and pc_category_id = c1.category_id;
  3.  
  4. SELECT tb1.* FROM categories AS tb1 JOIN products_categories AS tb2 ON tb1.category_id=tb2.category_id AND tb2.product_id IN (SELECT tb3.product_id FROM products AS tb3 JOIN products_categories AS tb4 ON tb3.product_id=tb4.product_id WHERE tb3.product_id=tb2.product_id)
Add Comment
Please, Sign In to add comment