如何使用两个表中的选择子句,连接它们并显示其中一个结果?

时间:2013-07-16 07:58:36

标签: php mysql sql database select

我从一个表中选择数据,但我还需要使用另一个表的选择条款:

sql& PHP:

  $condition = "
AND CONCAT_WS('-    ', products_description.products_id, products_attributes.products_attributes_id) = '".$product_number."' 
OR products_description.products_id = '".$product_number."'";

    $show_products_query_string = "
SELECT 
    products_description.products_id AS id,
    products_description.products_name AS product_name, 
    products.products_image AS product_image 
FROM 
    products_description 
    LEFT JOIN products ON products_description.products_id = products.products_id  
    LEFT JOIN warehouse_products ON products_description.products_id = warehouse_products.id" . $filter.$condition;

在这个查询中,我只需要显示我选择的内容:id,name,image_name。

提前谢谢!

0 个答案:

没有答案