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(3462, 3827, 3838, 3840, 4018, 4471, 4472, 4473, 4474, 5075, 6638, 6965, 7386, 9128, 9764, 9864, 10215, 10216, 10217, 10218, 10219, 11133, 11172, 11218, 11219, 11220, 11262, 11263, 11264, 11265, 11266, 11285, 11286, 11287, 11288, 11289, 11295, 11296, 11297, 11298, 11299, 11335, 11336, 11337, 11338, 11339, 11372, 11814, 11815, 11816, 11817, 11881, 11882, 11883, 11884, 11885, 11937, 11939, 11940, 11941, 11943, 12172, 12183, 12390, 12664, 12751, 12752, 12753, 12774, 12794, 12795, 12796, 12820, 12934, 13223, 13224, 13225, 13269, 13285, 13299, 13300, 13402, 13416, 13441, 13480, 13505, 13509, 13552, 13995, 14280, 14696, 14812, 14994, 15003, 15004, 15035, 15250, 15478, 15480, 16012, 16037, 16532, 16555, 17635, 17850, 18316, 18359, 18484, 18533, 18862, 19267, 19268, 19304, 19661, 19662, 19910, 19911, 19912, 20100, 20101, 20113, 20172, 20545, 20546, 20978, 21647, 22253, 22855, 23011, 23262, 23263, 23264, 23265, 23268, 23269, 23270, 23271, 23272, 23273, 23274, 23275, 23276, 23277, 23278, 23279, 23622, 23697, 24136, 24137, 24166, 24174, 24210, 24253, 24457, 24535, 24596, 24901, 24936, 25020, 25059, 25109, 25254, 25433, 25615, 26059, 26064, 26317, 26355, 26393, 26463, 26518, 26976, 27423, 27462, 27463, 27468, 27761, 27841, 27874, 27875, 28104, 28120, 28148, 28172, 28174, 28200, 28292, 28450, 28578, 28581, 28659, 28679, 28680, 28695, 28700, 28705, 28715, 28723, 28747, 28910, 28937, 28951, 28974, 28975, 29003, 29015, 29016, 29017, 29041, 29065, 29070, 29080, 29092, 29110, 29129, 29143, 29144, 29194, 29203, 29204, 29264, 29504, 29573, 29574, 29575, 29704, 29731, 29775, 29785, 29805, 29819, 29820, 29821, 29845, 29879, 29881, 29903, 29905, 29932, 29979, 29980, 29981, 29982, 29983, 30011, 30052, 30059, 30095, 30228, 30268, 30269, 30270, 30271, 30272, 30343, 30381, 30382, 30463, 30490, 30491, 30642, 30643, 30688, 30689, 30692, 30708, 30719, 30746, 30752, 30753, 30757, 30784, 30785, 30791, 30792, 30793, 30794, 30795, 30808, 30817, 30818, 30819, 30866, 30894, 30907, 30908, 30909, 30917, 30943, 30944, 30945, 30946, 30947, 30949, 30950, 31033, 31051, 31098, 31099, 31105, 31111, 31189, 31358, 31391, 31416, 31502, 31593, 31611, 31642, 31682, 31683, 31693, 31729, 31853, 31892, 31894, 31895, 31901, 31902, 31903, 31904, 31906, 31907, 31908, 31911, 31912, 31914, 31915, 31926, 31932, 31933, 31944, 31946, 31947, 31961, 31962, 31963, 31968, 31969, 31970, 31986, 31993, 31994, 31996, 32015, 32016, 32017, 32022, 32135, 32136, 32137, 32138, 32139, 32140, 32141, 32142, 32143, 32144, 32169, 32233, 32237, 32447, 32448, 32449, 32450, 32607, 32618, 32619, 32638, 32662, 32725, 32726, 32765, 32766, 32767, 32768, 32769, 32788, 32789, 32790, 32791, 32792, 32881, 32911, 32912, 32913, 32914, 32915, 32916, 32917, 32935, 32936, 32937, 32938, 32984, 32986, 32987, 32988, 32989, 33015, 33016, 33017, 33018, 33019, 33022, 33023, 33024, 33025, 33026, 33027, 33028, 33029, 33030, 33031, 33032, 33033, 33034, 33035, 33041, 33042, 33043, 33044, 33045, 33313, 33314, 33315, 33316, 33317, 33358, 33370, 33390, 33402, 33421, 33424, 33425, 33468, 33480, 33510, 33528, 33529, 33627, 33664, 33665, 33698) 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