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(37, 39, 47, 49, 50, 52, 197, 237, 267, 325, 424, 425, 437, 442, 745, 968, 971, 1000, 1272, 1302, 1303, 1304, 1395, 1400, 1401, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1479, 1480, 1707, 1864, 1968, 1969, 2039, 2065, 2420, 2421, 2708, 2821, 3048, 3049, 3050, 3051, 3120, 3154, 3155, 3217, 3239, 3451, 3496, 3640, 3755, 3911, 4041, 4044, 4045, 4082, 4088, 4089, 4090, 4091, 4092, 4099, 4109, 4128, 4129, 4130, 4131, 4132, 4161, 4252, 4437, 4456, 4462, 4591, 4634, 4667, 4679, 4736, 4871, 4888, 4912, 5003, 5018, 5057, 5132, 5249, 5250, 5268, 5275, 5317, 5432, 5490, 5600, 5734, 5746, 5747, 5887, 5989, 6061, 6072, 6101, 6102, 6121, 6225, 6292, 6297, 6298, 6299, 6300, 6301, 6315, 6317, 6428, 6605, 6663, 6718, 6756, 6771, 6777, 6856, 6929, 7269, 7322, 7545, 7753, 7952, 8009, 8047, 8068, 8123, 8154, 8183, 8228, 8244, 8273, 8277, 8338, 8358, 8365, 8378, 8379, 8444, 8448, 8615, 8834, 8969, 9003, 9099, 9126, 9145, 9175, 9233, 9374, 9491, 9530, 9655, 9772, 9782, 9796, 9797, 9798, 9821, 9917, 9980, 9994, 9995, 10057, 10079, 10159, 10423, 10467, 10511, 10519, 10526, 10545, 10598, 10619, 10625, 10728, 10730, 10768, 10851, 10875, 10936, 10956, 11014, 11015, 11062, 11216, 11341, 11361, 11369, 11659, 11664, 11667, 11961, 11996, 12064, 12209, 12292, 12490, 12558, 12585, 12594, 12637, 12659, 12735, 12767, 12792, 12793, 12951, 12969, 12971, 13015, 13030, 13086, 13108, 13195, 13199, 13204, 13240, 13314, 13317, 13578, 13609, 13698, 13833, 13867, 13878, 14013, 14290, 14413, 14430, 14434, 14465, 14509, 14532, 14585, 14633, 14639, 14684, 14740, 14753, 14858, 15106, 15188, 15388, 15411, 15459, 15571, 15573, 15579, 15586, 15592, 15627, 15628, 15657, 15743, 15875, 16078, 16079, 16486, 16564, 16881, 16923, 17240, 17243, 17255, 17256, 17377, 17621, 17844, 17871, 17916, 18057, 18247, 18390, 18640, 18789, 18845, 18858, 18866, 18867, 19235, 19273, 19418, 19437, 19453, 19529, 19690, 19705, 19724, 19762, 19773, 19896, 19918, 19967, 19978, 20011, 20098, 20109, 20403, 20404, 20617, 20618, 20648, 20663, 20747, 20989, 21060, 21064, 21081, 21117, 21250, 21278, 21456, 21670, 21674, 21747, 21756, 21822, 21873, 21897, 22116, 22166, 22176, 22219, 22286, 22287, 22552, 22715, 22766, 22770, 22787, 22788, 22790, 22823, 22871, 22912, 22982, 23007, 23024, 23040, 23042, 23076, 23142, 23193, 23195, 23450, 23472, 23473, 23474, 23475, 23490, 23512, 23678, 23729, 23736, 23744, 23885, 23891, 23993, 24046, 24151, 24154, 24188, 24237, 24346, 24352, 24363, 24367, 24582, 24781, 25024, 25094, 25104, 25111, 25167, 25321, 25332, 25475, 25689, 26073, 26093, 26196, 26219, 26383, 26420, 27056, 27078, 27133, 27143, 27802, 27927, 28072, 28250, 29300, 29722, 29764, 29895, 30045, 30046, 30362, 30363, 30432, 30453, 30763, 31079, 31200, 31322, 31365, 31884, 32078, 32485, 32740, 33552) 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