Answer the question
In order to leave comments, you need to log in
How to print the difference between two queries?
Hello.
There are three tables. Table A, table B and table C
A - goods, B - brands, C - suppliers
Field a.id_brand is associated with B. id
Table C and table B have the same id for identical manufacturers.
I need to select only those products that have a brand but no supplier.
That is, in this case, in the picture, only the product with ID = 5 - 5 - MMM - Reebok
As I understand it, you need to "subtract" tables B from table C and select only those products where id_brand is present in the "difference" of two tables.
Only I don’t understand something, how to do it in SQL
Please tell me =(
Answer the question
In order to leave comments, you need to log in
But if the vendor name is the same as the brand name, then brand id == vendor id
SELECT a.id, a.article, a.brand_id FROM a
INNER JOIN b on a.brand_id = b.id
LEFT JOIN c ON b.name = c.name
WHERE c.id IS NULL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question