mysql内连接查询

时间:2014-10-16 16:06:47

标签: mysql sql inner-join

我的产品表上的以下内部联接查询出现问题 - >>

SELECT   products.prod_id, products.prod_name, products.price, suppliers.company_name, customers.phone,
     FROM products
     INNER JOIN suppliers
     ON suppliers.supp_id = suppliers.supp_ID;

1 个答案:

答案 0 :(得分:1)

您正加入suppliers.supp_id = suppliers.supp_ID;

两者都来自供应商表...您需要产品表中的属性。类似的东西:

products.supp_id = suppliers.supp_ID;

这将导致以下查询:

    SELECT   
       products.prod_id, 
       products.prod_name, 
       products.price, 
       suppliers.company_name, 
       customers.phone
    FROM 
       products
    INNER JOIN 
       suppliers
    ON 
       products.supp_id = suppliers.supp_ID;