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(1139, 1140, 1894, 2156, 2157, 2160, 2640, 3054, 3144, 3187, 3197, 3219, 3220, 3521, 3533, 3693, 3747, 3842, 4025, 4075, 4560, 4721, 4722, 4827, 4996, 5010, 5209, 5212, 5238, 5360, 5417, 5779, 6031, 6032, 6033, 6329, 6406, 6614, 6824, 6959, 7020, 7140, 7144, 7207, 7379, 7558, 7560, 7947, 8267, 8383, 8384, 8566, 8576, 8577, 8598, 8757, 8758, 8792, 8794, 8877, 9028, 9482, 9490, 9513, 9740, 9753, 9873, 10442, 10443, 10475, 10540, 10686, 10715, 10734, 10829, 10832, 10834, 10835, 10854, 10858, 10987, 10988, 11002, 11003, 11051, 11052, 11053, 11141, 11142, 11143, 11245, 11291, 11378, 11503, 11582, 11591, 11633, 11704, 11807, 11830, 11894, 12137, 12138, 12228, 12606, 12683, 12813, 12882, 12948, 13115, 13188, 13203, 13318, 13319, 13320, 13359, 13518, 13568, 13696, 13737, 14148, 14274, 14275, 14353, 14354, 14359, 14416, 15085, 15127, 15257, 15360, 15441, 15464, 15466, 15515, 15523, 15599, 15678, 15707, 15777, 15798, 16088, 16237, 16321, 16364, 16458, 16483, 16484, 16487, 16542, 16560, 16618, 16619, 16620, 16621, 16643, 16671, 16827, 16838, 16931, 16932, 16938, 16939, 16940, 16941, 16942, 16951, 16952, 16953, 16954, 16959, 16984, 16985, 16986, 16987, 16988, 17007, 17137, 17148, 17156, 17157, 17198, 17217, 17228, 17230, 17302, 17354, 17355, 17365, 17397, 17416, 17417, 17418, 17707, 18008, 18012, 18013, 18015, 18016, 18030, 18183, 18294, 18297, 18298, 18304, 18307, 18317, 18324, 18325, 18362, 18512, 18529, 18595, 18596, 18597, 18671, 18673, 18854, 19017, 19021, 19143, 19303, 19331, 19496, 19568, 19634, 19985, 19987, 20040, 20041, 20114, 20151, 20193, 20348, 20349, 20352, 20371, 20402, 20477, 20676, 20701, 20846, 20849, 20850, 20851, 20958, 20983, 21071, 21217, 21218, 21221, 21291, 21377, 21378, 21379, 21380, 21424, 21470, 21525, 21550, 21596, 21597, 21599, 21831, 21955, 22155, 22272, 22281, 22282, 22360, 22389, 22391, 22392, 22398, 22432, 22453, 22480, 22510, 22809, 22963, 23091, 23109, 23159, 23198, 23199, 23200, 23201, 23202, 23213, 23214, 23425, 23478, 23748, 23759, 23775, 23799, 23812, 23947, 23955, 24424, 24475, 24843, 24853, 24950, 24951, 25000, 25133, 25240, 25323, 25325, 25565, 25602, 25881, 26110, 26345, 26495, 26597, 26600, 26640, 26974, 28206, 28968, 29329, 29729, 30162, 30187, 30235, 30287, 30288, 30291, 30378, 30654, 30685, 30721, 30728, 30729, 30732, 30733, 30734, 30735, 30736, 30743, 30948, 31057, 31058, 31088, 31229, 31323, 31357, 31368, 31495, 31540, 31575, 31604, 31605, 31733, 31737, 31738, 31764, 31765, 31767, 31768, 31769, 31771, 31773, 31774, 31777, 31778, 31780, 31782, 31784, 31796, 31797, 31798, 31801, 31802, 31803, 31804, 31805, 31806, 31934, 31935, 31960, 32160, 32163, 32167, 32168, 32481, 32552) 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