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(26, 294, 362, 365, 371, 563, 649, 752, 1390, 2084, 3890, 4199, 4396, 4983, 4984, 5991, 7255, 7546, 8259, 8391, 9256, 10202, 11942, 14692, 15248, 15629, 15663, 16005, 16696, 18657, 20664, 20940, 22585, 23141, 26062, 26320, 28506, 29345) 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