Answer the question
In order to leave comments, you need to log in
How to make a condition for joining tables on several fields in LEFT JOIN?
There are two tables. In the `names` table, the fields are: `id`, `name`, `street`, `house`. In the table `professions` the fields are: `id`, `profession`, `street`, `house`. That is, in fact, the addresses are divided into two fields: street and house.
The question is how to join these LEFT JOIN tables with the condition that streets and houses coincide at the same time? I do like this, but it returns NULL instead of values from the second table:
SELECT `names`.`name`, `professions`.`profession`
FROM `names`
LEFT JOIN `professions`
ON `names`.`street` = `professions`.`street` AND `names`.`house` = `professions`.`house`
Answer the question
In order to leave comments, you need to log in
Actually syntactically everything is correct. The question is in the real match of rows in tables (spaces, encodings, etc.)
What will join only with the first and only the second condition give?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question