Answer the question
In order to leave comments, you need to log in
Why doesn't INNER JOIN work?
Good afternoon.
There are two tables - A and B. I'm trying to display all records from tables A and B that have the condition A.id = B.id and A.id_order is equal to a certain value. I wrote this query for this:
SELECT A.id, B.price
FROM `table_A` as A
INNER JOIN `table_B` as B ON A.id = B.id
WHERE A.id_order = 100
Answer the question
In order to leave comments, you need to log in
it means that in table B there is no id that matches the id in table A, for which A.id_order=100
to check, do
SELECT DISTINCT(id) FROM table_A WHERE id_order=100
SELECT DISTINCT(id) FROM table_В
SELECT * FROM table_В WHERE id IN (SELECT DISTINCT(id) FROM table_A WHERE id_order=100)
- should return an empty list here. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question