SELECT s.id, s.extra, ss.ref_seminarka FROM seminarka AS s LEFT JOIN seminarka_spisovatel AS ss ON s.id = ss.ref_seminarka WHERE s.id IN(3491, 13080, 14631, 17362, 20248, 20300, 20466, 22199, 22583, 24260, 24265, 24733, 27518, 29141, 29142, 29986, 31112, 31437, 31439, 31441, 31742) and s.autorizace >0 and s.id in (select distinct STR_SEMINARKA_FK from strom where STR_SEMINARKA_TYP_FK in (2, 4, 20) or (STR_SEMINARKA_TYP_FK=17 and STR_SUBKATEGORIE_FK=247) or (STR_SEMINARKA_TYP_FK in (18, 1, 9, 11) and STR_SUBKATEGORIE_FK in (117, 342))) GROUP BY s.id