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(476, 1474, 1475, 2155, 3151, 3308, 3365, 3912, 4060, 4425, 4770, 5535, 5536, 5538, 5542, 5543, 6056, 6057, 6058, 7128, 7129, 8236, 8493, 8823, 9159, 9542, 9741, 9762, 9763, 10075, 10320, 11063, 11176, 11599, 11600, 12301, 12430, 12463, 12601, 12737, 12797, 12962, 13993, 13997, 14298, 14392, 14551, 14552, 14901, 15959, 16120, 16763, 16766, 17116, 18143, 18494, 18734, 18775, 19216, 19339, 19961, 20216, 20524, 20710, 20711, 20980, 20982, 22449, 22450, 22569, 23413, 23432, 23892, 23944, 26217, 28055, 28711, 29464, 31356, 31751, 31754, 31755, 31759, 31762, 31786, 31807, 31808, 31809, 31811, 31812, 31813, 31814, 31815, 31819, 31853, 32154, 32321, 32328, 32333, 33418, 33420, 33577, 33578, 33579, 33580, 33581, 33582, 33583, 33584, 33585, 33586, 33592, 33593, 33594, 33595, 33596) 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