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(16, 262, 288, 422, 434, 476, 533, 550, 577, 623, 632, 733, 746, 765, 781, 801, 824, 839, 882, 884, 893, 936, 1022, 1044, 1046, 1048, 1051, 1053, 1054, 1055, 1056, 1110, 1501, 1502, 1505, 1506, 1700, 1921, 2091, 2093, 2094, 2520, 2521, 2632, 2636, 2637, 2792, 2793, 2794, 2795, 2796, 2798, 2800, 2801, 2802, 2804, 2809, 2810, 2811, 2812, 2813, 2814, 2924, 3163, 3202, 3225, 3259, 3291, 3318, 3512, 3573, 3690, 3706, 3716, 3738, 3739, 3797, 3970, 3979, 3980, 3981, 4150, 4204, 4208, 4423, 4559, 4589, 4743, 4747, 4766, 4797, 4854, 4855, 5037, 5058, 5192, 5239, 5672, 5678, 5782, 6127, 6461, 6462, 6477, 6799, 6845, 6877, 7254, 7265, 7268, 7327, 7396, 7449, 7450, 7525, 7579, 7657, 7736, 7763, 7868, 8022, 8063, 8092, 8173, 8175, 8230, 8362, 8410, 8528, 8601, 8696, 8778, 8812, 8966, 9247, 9249, 9347, 9382, 9593, 9685, 9695, 9997, 9999, 10052, 10162, 10328, 10382, 10436, 10439, 10455, 10569, 10690, 10783, 10785, 11065, 11092, 11093, 11121, 11124, 11176, 11235, 11249, 11292, 11421, 11440, 11583, 11623, 11758, 11759, 11827, 11953, 11967, 12001, 12067, 12068, 12071, 12092, 12151, 12288, 12432, 12491, 12684, 12855, 12898, 12917, 13088, 13237, 13238, 13246, 13570, 13621, 13654, 13820, 13940, 14044, 14074, 14129, 14151, 14152, 14393, 14636, 14698, 14730, 14772, 14802, 15008, 15019, 15063, 15120, 15201, 15242, 15724, 15725, 15757, 15849, 15942, 15957, 15967, 15968, 16087, 16106, 16600, 16623, 16624, 16625, 16701, 17048, 17068, 17311, 17312, 17442, 17443, 17444, 17445, 17446, 17477, 17478, 17479, 17488, 17537, 17673, 17728, 18090, 18140, 18147, 18184, 18234, 18429, 18451, 18579, 18623, 18802, 18808, 18840, 18891, 18928, 18955, 19024, 19154, 19162, 19165, 19168, 19173, 19197, 19205, 19206, 19207, 19360, 19435, 19472, 19473, 19474, 19475, 19479, 19787, 19829, 19873, 19883, 20149, 20217, 20304, 20305, 20563, 20613, 20713, 20844, 20865, 20866, 20881, 20894, 20987, 21123, 21187, 21292, 21589, 21607, 21717, 21744, 21878, 22098, 22192, 22204, 22209, 22328, 22358, 22368, 22379, 22406, 22445, 22485, 22523, 22688, 22720, 22728, 22740, 22899, 22904, 22905, 22952, 22984, 22985, 22986, 23032, 23100, 23107, 23147, 23175, 23280, 23941, 23980, 24179, 24198, 24404, 24620, 24669, 24697, 24744, 24759, 24761, 24764, 24770, 24968, 24989, 25040, 25262, 25271, 25297, 25510, 25953, 26230, 26346, 26418, 26496, 26861, 27336, 27668, 27669, 27828, 28002, 28035, 28071, 28084, 28121, 28241, 28242, 28617, 29078, 29199, 29201, 29776, 29777, 29778, 29779, 29806, 29943, 30060, 30081, 30146, 30404, 30630, 30933, 31596, 31598, 31771, 32234, 32235, 32354, 32381, 32382, 32384, 32385, 32386, 32387, 32388, 32394, 32395, 32542, 32543, 32544, 32801, 32802, 32803, 32804, 32805, 32810, 33318) 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