SELECT Id, Name, Lastname
FROM customers AS c, Places AS p,
WHERE c.customer_ID = p.customer_ID
My problem is that, i want to prevent the result of the query of showing a row that exist in another table(stages)
SELECT Id, Name, Lastname
FROM customers AS c, Places AS p,
WHERE c.customer_ID = p.customer_ID
My problem is that, i want to prevent the result of the query of showing a row that exist in another table(stages)
You can do a LEFT JOIN and check for null.
SELECT Id, Name, Lastname
FROM customers AS c LEFT JOIN Places AS p ON c.customer_ID = p.customer_ID
WHERE p.customer_ID IS NULL
add
and not exists
(subquery to select your exclusions)
to your query
You could use:
SELECT Id, Name, Lastname
FROM customers AS c JOIN Places AS p USING(customer_ID)
This is faster way that you could make with in/exists
.
I suppose you want something like this:
SELECT Id, Name, Lastname
FROM customers,
WHERE customer_ID NOT IN (SELECT customer_ID FROM Places)