I am very new to MySQL queries and I'm trying to do a large SQL query from multiple tables. I have three tables, customer, order, and food. They are similar to the following:
customer
id  |  order_id  | purchase_category
----+------------+------------------
1   |  123       |  'Sandwich'
2   |  456       |  'Item'
3   |  789       |  'Dessert'
4   |  NULL      |  'Item'
order
order_id  |  payment_method
---------------------------
123       |  'credit_card'
456       |  'debit_card'
food
id  |  type
-----------
1   |  'Burger'
3   |  'Cake'
item
id  |  product
--------------
2   |  'Stickers'
4   |  'Game'
I am trying to find the fields by the id. My desired output from a SQL query is this, if looking for id 1:
order_id  |  purchase_category  |  payment_method  |  type    |  product
----------------------------------------------------------------------
123       |  'Sandwich'         |  'credit_card'   | 'Burger' |  NULL
And if looking for id 2:
order_id  |  purchase_category  |  payment_method  |  type    |  product
----------------------------------------------------------------------
456       |  'Item'             |  'debit_card     | NULL     |  'Stickers'
And if looking for id 3:
order_id  |  purchase_category  |  payment_method  |  type    |  product
----------------------------------------------------------------------
789       |  'Dessert'          |  NULL            | 'Cake'   |  NULL
And if looking for id 4:
order_id  |  purchase_category  |  payment_method  |  type    |  product
----------------------------------------------------------------------
NULL      |  'Item'             |  NULL            |  NULL    |  'Game'
Notice how in the tables, an ID may not exist in the table, but I still want to return the desired fields as NULL if the ID does not exist in the table. I have researched extensively to try to find the solution and I can't seem to get it. Here is the code I have written so far:
SELECT customer.order_id, customer.purchase_category, order.payment_method, food.type, item.product
FROM customer, food, item
LEFT JOIN order
ON customer.order_id=order.order_id
WHERE customer.id=1 and food.id=1 and item.id=1 
However when an id does not exist in one of the tables, the whole thing returns the empty set. I just need the desired fields to populate with NULL in this case. I also need to protect against when an order_id is NULL in the customer table, e.g. output when looking for id 4.
 
     
     
    