I have a table “products” and a table “orders”
the Orders table has the following fields: “id_products” and “id_users”
to join the two tables then write:
SELECT * FROM products as p LEFT JOIN orders as o ON p.id_products=o.id_products
I would like to create a JOIN with all the products you have ordered the user with id 1 and products that still have to order.
Edit:
SELECT * FROM products LEFT JOIN orders
ON products.id_products= orders.id_products
WHERE user_id = 1 OR user_id IS NULL
1 Answer