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(205, 291, 339, 486, 504, 532, 534, 692, 832, 942, 943, 944, 946, 994, 1284, 1500, 1873, 1929, 2017, 2032, 2033, 2744, 2782, 2783, 2784, 2786, 2787, 2788, 2889, 2890, 2891, 2893, 2900, 3047, 3122, 3213, 3248, 3275, 3313, 3445, 3473, 3503, 3539, 3618, 3676, 3777, 3786, 3991, 3997, 3998, 3999, 4012, 4013, 4014, 4016, 4022, 4042, 4061, 4065, 4101, 4152, 4154, 4155, 4156, 4289, 4340, 4377, 4511, 4598, 4677, 4678, 4696, 4856, 5005, 5488, 5552, 5595, 5628, 5971, 6306, 6338, 6402, 6531, 7166, 7403, 7507, 7521, 7577, 7634, 7635, 7637, 7638, 7707, 8684, 8694, 9024, 9340, 9558, 9667, 9672, 9907, 10009, 10301, 10501, 10658, 10669, 10697, 10713, 10775, 11177, 11178, 11269, 11723, 11794, 11965, 11966, 11976, 12109, 12111, 12221, 12235, 12242, 12243, 12424, 12442, 12472, 12573, 12638, 12644, 12712, 12713, 12799, 12946, 13102, 13124, 13197, 13198, 13213, 13262, 13379, 13501, 13725, 13815, 13944, 14042, 14317, 14395, 14478, 14718, 15050, 15373, 15467, 15580, 15767, 15984, 16071, 16091, 16099, 16102, 16261, 16403, 16699, 16718, 16728, 16732, 16869, 17172, 17266, 17483, 17484, 17486, 17487, 17490, 17514, 17515, 17516, 17517, 17518, 17632, 17835, 17891, 17896, 17907, 18052, 18065, 18080, 18120, 18121, 18164, 18240, 18258, 18346, 18404, 18405, 18406, 18436, 18438, 18439, 18440, 18526, 18572, 18601, 18620, 18651, 18866, 18880, 18958, 18991, 19060, 19098, 19125, 19236, 19272, 19329, 19421, 19423, 19424, 19425, 19431, 19468, 19492, 19498, 19682, 19697, 19791, 19863, 19887, 19890, 19898, 20092, 20139, 20140, 20141, 20142, 20154, 20184, 20187, 20204, 20210, 20220, 20231, 20246, 20412, 20424, 20434, 20641, 20705, 20919, 21175, 21191, 21216, 21227, 21228, 21229, 21230, 21306, 21427, 21463, 21627, 21629, 21970, 22097, 22203, 22350, 22375, 22421, 22422, 22447, 22513, 22575, 22603, 22714, 22806, 22846, 22925, 22926, 22931, 23086, 23103, 23169, 23211, 23826, 23827, 23857, 24576, 24578, 24880, 25368, 25386, 25562, 25616, 25617, 25678, 25882, 25883, 25885, 25886, 25891, 25892, 25893, 25894, 25993, 26099, 26101, 26119, 26177, 26212, 26243, 26255, 26264, 26272, 26281, 26282, 26374, 26386, 26416, 26472, 26473, 26843, 27197, 27840, 28048, 28082, 28287, 29866, 29893, 29908, 30356, 31498, 31601, 31847, 32187, 32819) 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