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(652, 700, 760, 890, 1073, 1112, 1669, 1670, 1671, 1672, 1675, 1676, 2129, 2132, 2475, 2982, 3826, 3935, 3936, 4053, 4085, 4086, 4087, 4127, 4158, 4380, 4381, 4382, 4973, 5252, 5300, 5452, 5453, 5454, 5455, 5456, 5673, 5674, 5675, 5998, 7323, 7324, 7411, 7660, 8108, 8248, 8978, 9051, 9749, 9844, 9945, 10409, 10622, 11904, 11905, 12051, 12118, 12142, 12345, 12582, 13062, 13360, 14346, 14390, 14429, 14515, 14857, 14872, 14873, 14874, 15700, 15922, 16452, 18501, 19378, 20448, 20629, 21019, 21540, 22309, 22310, 22311, 22312, 22313, 22316, 22430, 22860, 22909, 22916, 22936, 23050, 23051, 23126, 23427, 23431, 23479, 23488, 23566, 24851, 24948, 24991, 25080, 25127, 25169, 25380, 25392, 25417, 25443, 25480, 26330, 26635, 26730, 27277, 27568, 27664, 27950, 28022, 28284, 28307, 28793, 28794, 28795, 28797, 28798, 28799, 28800, 29160, 29161, 29162, 29163, 29164, 29184, 29185, 29186, 29187, 29188, 29192, 29193, 29194, 29195, 29196, 29293, 29294, 29295, 29296, 29297, 29467, 29920, 29921, 29922, 29923, 29924, 30071, 30178, 30321, 30579, 30580, 30581, 30582, 30843, 30900, 31014, 31016, 31036, 31109, 31110, 31139, 31174, 31191, 31197, 31198, 31221, 31291, 31292, 31309, 31316, 31318, 31359, 31618, 31678, 31900, 31909, 31988, 32007, 32073, 32074, 32075, 32076, 32077, 32186, 32225, 32241, 32242, 32245, 32264, 32571, 32961, 33002, 33071, 33083, 33335, 33336, 33532, 33533) 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