There are two tables:
customers(id int PRIMARY KEY, firstname , lastname, address)
and
orders(id, product_name, product_price, date_order, id_customer int FOREIGN KEY, amount)
I need to get first and last names of all customers table and appropriate product_names from orders table, also show customers without orders and orders without customers (if any) Sort the data by firstname, lastname and product name P.S. The SQL version does not support FULL JOIN
My query is:
SELECT customers.firstname, customers.lastname, orders.product_name
FROM customers
LEFT JOIN orders ON customers.id = orders.id_customer
WHERE customers.id IS NULL AND orders.id_customer IS NULL
ORDER BY customers.firstname, customers.lastname, orders.product_name;
Is this query correct or can I use right join also so that I would get complex join or not ?