I was doing an exercise and I am stuck on it. There are 2 tables:
The query:
SELECT Orders.product_name, Customers.firstname, Customers.lastname
FROM Orders INNER JOIN
Customers
ON Orders.id_customer=Customers.id
ORDER BY Orders.id;
Expected result:
Show the list of all products' names ordered along with first and last names of the customers.
Include in the result only those customers who have no address in a database and sort the data by Orders.id
.
Looks like you're pretty close. You just need a WHERE
clause to match this requirement:
Include to the result only those customers who has no address in a database
Try this:
SELECT Orders.product_name, Customers.firstname, Customers.lastname
FROM Orders INNER JOIN Customers ON Orders.id_customer = Customers.id
WHERE address IS NULL OR address = ''
ORDER BY Orders.id;