I have a query that looks like this:
SELECT u_s_date, u_s_customer, u_s_product_name, u_f_quantity FROM updated
JOIN accounts ON `name` = u_s_customer
WHERE deleted = 0;
That compares of list in a table called updated
of 400 product orders. I am joining to a table of accounts
because not all customer names from the updated
table are in the accounts
table. So that takes the list from 400 to about 300 names.
What I need is to now make another list of the 100 rows that are not being included.
I tried things like JOIN accounts ON `name` <> u_s_customer
and that obviously didn't work. I am not good with subqueries and conditions and I am afraid that is the only way to do this.
Can someone give me some help on this?
EXISTS OPERATOR
SELECT *
FROM updated u
WHERE NOT EXISTS (SELECT 1
FROM accounts
WHERE `name` = u_s_customer)
LEFT JOIN
SELECT *
FROM updated LEFT JOIN accounts
ON `name` = u_s_customer
WHERE name IS NULL
NOT IN
SELECT *
FROM updated
WHERE name NOT IN (SELECT u_s_customer
FROM accounts )
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments