SELECT drug.`name`, `countries`.`name` AS country, drug.`ftg_id`, drug.`owner_id`, `owners`.`name` AS owner, `owners`.`short` AS brand, `owners`.`url` AS owner_url, drug.`cat_id`,`forms_cat`.`name` AS cat_name, `atx_id`, GROUP_CONCAT(DISTINCT `forms`.`doz` SEPARATOR '; ') AS dozes, GROUP_CONCAT(DISTINCT `drug2substance`.`subs_id` ORDER BY 1) AS subs, GROUP_CONCAT(DISTINCT subs.`name` ORDER BY 1 SEPARATOR ', ') AS subs_names FROM (SELECT `id`, `cat_id`, `name`, `country_id`, `ftg_id`, `owner_id` FROM `drugs` WHERE `title_id`=? AND (`regEnd` IS NULL OR `regEnd` > DATE(NOW())) ) drug LEFT JOIN `countries` ON drug.`country_id` = `countries`.`id` LEFT JOIN `owners` ON `owners`.`id` = drug.`owner_id` LEFT JOIN `forms` ON `forms`.`drug_id` = drug.`id` LEFT JOIN `forms_cat` ON drug.`cat_id` = `forms_cat`.`id` LEFT JOIN `drug2atx` ON `drug2atx`.`drug_id` = drug.`id` LEFT JOIN `drug2substance` ON drug.`id` = `drug2substance`.`drug_id` LEFT JOIN (SELECT `id`, `name` FROM `substances` WHERE `id` NOT IN ()) subs ON subs.`id` = `drug2substance`.`subs_id` GROUP BY `forms_cat`.`id`, drug.`owner_id` ORDER BY `forms_cat`.`id`;
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) subs ON subs.`id` = `drug2substance`.`subs_id` GROUP BY `form' at line 17