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(3, 4, 28, 185, 189, 379, 441, 445, 448, 454, 492, 513, 594, 615, 810, 1047, 1178, 1179, 1180, 1181, 1182, 1183, 1482, 1483, 1484, 1485, 1650, 1928, 2166, 2448, 3036, 3203, 3320, 3884, 3885, 3886, 4708, 4798, 5785, 5919, 6048, 6127, 6933, 6935, 7068, 8020, 9780, 9900, 10085, 10223, 10744, 10786, 10899, 11066, 12145, 12647, 12779, 13806, 13808, 14060, 14216, 15417, 15420, 15555, 15717, 16450, 16756, 16772, 16823, 17061, 17334, 17490, 17928, 18553, 18605, 19122, 19225, 19300, 19412, 19430, 19478, 19495, 19727, 19851, 19852, 20415, 20427, 20499, 20507, 20509, 20906, 21015, 21035, 21230, 21432, 21435, 21443, 21768, 21839, 21849, 21891, 22024, 22169, 22264, 22479, 22504, 22720, 22774, 22832, 22910, 23414, 23438, 23441, 23460, 23465, 23476, 23582, 23662, 23665, 23821, 23980, 24026, 24058, 24060, 24063, 24069, 24077, 24079, 24080, 24089, 24117, 24163, 24165, 24179, 24213, 24494, 25145, 25215, 25327, 25346, 25349, 28571, 28572, 30004, 30085, 31254, 31890, 33046, 33047, 33048, 33049, 33050, 33055) 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