Answer the question
In order to leave comments, you need to log in
How to display multiple cells from different tables with different conditions?
You need to display the full address of the student Petrov (region, city, street, house and apartment).
I can output one column like "Region" like in the following query. And how to bring the rest after him?
SELECT `nazvanie` AS 'Регион'
FROM `region`
WHERE `kod_region` = ( SELECT `kod_region` FROM `gorod` WHERE `kod_gorod`
= ( SELECT `kod_gorod` FROM `ulica` WHERE `kod_ulica`
= ( SELECT `kod_ulica` FROM `dannie` WHERE `fam` = 'Петров')))
Answer the question
In order to leave comments, you need to log in
Try something like this:
SELECT `nazvanie` , `gorod`, `ulica`
FROM `dannie` as D LEFT JOIN `ulica` as U on D.`kod_ulica` = U.`kod_ulica`
LEFT JOIN `gorod` as G on U.`kod_gorod` = G.`kod_gorod`
LEFT JOIN `region` as R on G.`kod_region` = R.`kod_region`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question