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(19, 21, 35, 37, 143, 144, 147, 222, 251, 306, 314, 329, 330, 331, 332, 381, 462, 511, 522, 676, 776, 939, 955, 982, 983, 986, 1014, 1119, 1144, 1301, 1336, 1337, 1338, 1339, 1341, 1342, 1663, 1722, 1804, 1816, 1919, 2023, 2071, 2072, 2193, 2313, 2403, 2404, 2408, 2409, 2410, 2411, 2415, 2416, 2472, 2541, 2721, 2722, 2732, 2738, 2818, 3250, 3251, 3288, 3321, 3377, 3471, 3500, 3529, 3548, 3611, 3720, 3732, 3779, 3843, 4069, 4139, 4457, 4498, 4592, 4635, 4700, 4701, 4783, 4784, 4795, 4891, 4900, 4907, 4968, 5019, 5020, 5051, 5100, 5344, 5556, 5607, 5639, 5700, 5921, 6237, 6621, 6659, 6753, 6755, 6778, 6786, 6800, 6854, 6855, 6857, 7005, 7014, 7121, 7138, 7213, 7381, 7530, 7539, 7541, 7804, 7888, 7966, 8260, 8261, 8263, 8284, 8285, 8286, 8287, 8352, 8371, 8447, 8585, 8604, 8712, 8714, 8825, 8844, 9021, 9081, 9125, 9202, 9225, 9239, 9259, 9279, 9420, 9522, 9690, 9692, 9719, 9778, 9838, 9928, 9955, 9983, 10036, 10164, 10229, 10310, 10367, 10623, 10750, 10812, 10957, 11016, 11114, 11258, 11283, 11301, 11344, 11484, 11572, 11595, 11642, 11643, 11701, 11726, 11737, 11800, 11804, 11931, 11959, 12159, 12346, 12439, 12540, 12764, 12960, 13076, 13103, 13247, 13311, 13430, 13438, 13548, 13581, 13586, 13898, 13932, 13965, 14147, 14180, 14186, 14217, 14218, 14305, 14315, 14550, 14623, 14655, 14656, 14659, 14677, 14693, 14714, 14733, 14742, 14890, 14905, 14983, 15071, 15240, 15252, 15267, 15286, 15325, 15333, 15415, 15497, 15498, 15571, 15572, 15583, 15585, 15658, 15666, 15683, 15684, 15746, 15768, 15794, 15848, 15976, 15993, 16019, 16020, 16057, 16264, 16569, 16660, 16693, 17104, 17106, 17117, 17154, 17165, 17265, 17310, 17313, 17319, 17337, 17404, 17432, 17652, 17661, 17689, 17710, 17744, 17745, 17748, 17945, 18001, 18078, 18116, 18170, 18186, 18224, 18354, 18363, 18422, 18423, 18485, 18519, 18538, 18648, 18665, 18668, 18669, 18787, 18850, 18927, 18947, 18957, 19068, 19107, 19132, 19236, 19253, 19294, 19426, 19433, 19452, 19476, 19493, 19518, 19557, 19617, 19618, 19651, 19663, 19664, 19677, 19684, 19723, 19769, 19788, 19789, 19857, 19884, 19885, 19886, 19889, 19928, 19929, 20121, 20122, 20201, 20230, 20231, 20312, 20364, 20365, 20428, 20432, 20434, 20435, 20560, 20733, 20737, 20778, 20779, 20780, 20821, 20903, 20938, 20999, 21029, 21082, 21083, 21246, 21260, 21328, 21364, 21367, 21503, 21574, 21608, 21609, 21653, 21783, 21784, 21800, 22059, 22101, 22110, 22210, 22211, 22212, 22213, 22214, 22244, 22245, 22508, 22513, 22596, 22597, 22780, 22791, 22807, 22862, 22863, 22864, 22865, 22890, 22914, 22915, 23025, 23026, 23028, 23117, 23186, 23300, 23515, 23859, 23986, 24214, 24293, 24327, 24331, 24346, 24347, 24352, 24355, 24365, 25043, 25094, 25095, 25096, 25101, 25110, 25153, 25223, 25232, 25267, 25601, 25824, 25986, 26124, 26163, 26401, 26419, 26534, 27008, 27145, 27305, 27310, 27384, 27494, 27497, 27532, 27537, 27544, 27559, 27940, 28095, 28137, 28253, 28367, 29800, 30712, 31059, 31500, 31557, 31558, 31559, 31560, 31565, 31567, 31570, 31571, 31572, 31573, 31747, 32538, 32563) 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