Skip to main content
Known Participant
January 25, 2023
Question

joining 2 tables and select data with $_get function

  • January 25, 2023
  • 2 replies
  • 180 views

Hi all,

 How can i join 2 tables with a condition that product.menu_type = ClothingType.menu_type  = $menu_type?

    This topic has been closed for replies.

    2 replies

    Community Expert
    January 25, 2023

    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;

     

    Community Expert
    January 25, 2023

    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?