SELECT title AS city title AS phone FROM clients AS LEFT JOIN SELECT t

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
SELECT
`u`.*,
`c`.`title` AS `city`,
`p`.`title` AS `phone`
FROM
`clients` AS `u`
LEFT JOIN
(SELECT `title`, `client_id` FROM `clients_contacts` WHERE `type` = 1) AS `c`
ON
`u`.`id` = `c`.`client_id`
LEFT JOIN
(SELECT `title`, `client_id` FROM `clients_contacts` WHERE `type` = 3) AS `p`
ON
`p`.`client_id` = `u`.`id`;