0

我有一个表“产品”和一个表“订单”,订单表有以下字段:“id_products”和“id_users”加入这两个表然后写:

SELECT * FROM products as p LEFT JOIN orders as o ON p.id_products=o.id_products

我想创建一个 JOIN,其中包含您订购的用户 ID 为 1 的所有产品以及仍需订购的产品。

编辑:

SELECT * FROM products LEFT JOIN orders 
ON products.id_products= orders.id_products
WHERE user_id = 1 OR user_id IS NULL
4

2 回答 2

2
SELECT * FROM products LEFT JOIN orders 
ON products.id_products= orders.id_products
Where user.id = 1
于 2012-11-21T11:03:50.340 回答
0

才不是

SELECT * FROM products as p LEFT OUTER JOIN orders as o ON p.id_products=o.id_products  
where id_users = 1

做你想做的事?

于 2012-11-21T11:01:54.717 回答