SELECT `g`.`id`, `g`.`name`, `g`.`description`, `g`.`price`, `i`.`images`
FROM `goods` AS `g`
LEFT JOIN (
SELECT `good_id`, GROUP_CONCAT(`link` SEPARATOR ',') AS `images`
FROM `images`
GROUP BY `good_id`
) AS `i` ON `i`.`good_id` = `g`.`id`
WHERE `g`.`id_category` = :category
ORDER BY `g`.`id` DESC;
SELECT `a`.`name`, IFNULL(`c`.`count`, 0)
FROM `author_user` AS `au`
JOIN `authors` AS `a` ON `au`.`user` = :user AND `a`.`id` = `au`.`author_id`
LEFT JOIN (
SELECT `p`.`author_id`, COUNT(*) AS `count`
FROM `posts` AS `p`
LEFT JOIN `post_user` AS `pu` ON `pu`.`user_id` = :user AND `pu`.`post_id` = `p`.`id`
WHERE `pu`.`post_id` IS NULL
GROUP BY `p`.`author_id`
) AS `c` ON `c`.`author_id` = `au`.`author_id`
$art_content['title'] = $row['title'];
$art_content['date'] = $row['date'];
...
SELECT `s`.`id`, ...
FROM `student` AS `s`
LEFT JOIN (
SELECT DISTINCT `c`.`student_id` AS `student_id`
FROM `contract` AS `c`
JOIN `contract_discipline` AS `cd`
ON `cd`.`contract_id` = `c`.`id` AND `cd`.`discipline_id` = :discipline_id
) AS `c` ON `c`.`student_id` = `s`.`id`
WHERE `c`.`student_id` IS NULL
ORDER BY FIELD(`p`.`product_id`, 574, 572, 573)