Copy link to clipboard
Copied
Hi all,
How can i join 2 tables with a condition that product.menu_type = ClothingType.menu_type = $menu_type?
Copy link to clipboard
Copied
The AND in your statement doesn't make sense and seems to be incomplete. It just says "Product.menu_type =". Have you tried running your query with that statement complete or without the AND clause to see what happens?
Copy link to clipboard
Copied
Maybe I don't correctly understand your question, but it seems to me that you are confusing two equality principles that you are trying to pass at the join level, in fact, if I undesratnd quite well, there are two types of equality, one at the join level, but a second at the query level;
try with this type of query and let us know if it matches your expectation;
$sql ="SELECT Product.id, Product.menu_type, Product.name, Product.price, Product.Pic, ClothingType.menu_type FROM Product INNER JOIN ClothingType ON Product.menu_type=ClothingType.menu_type WHERE Product.menu_type =".$menu_type;