C_query: SELECT count(*) FROM (SELECT DISTINCT(k.kid) AS d_kid, k.*, l.laad FROM (SELECT distinct(k.kid) AS kid, k.aisnull, k.a100, k.p245, CONCAT(IFNULL(k.a100, ''), k.p245) AS combi, k.aastamax, k.aastamin FROM `jarjestus` AS k JOIN sonad AS s1 ON s1.kid=k.kid AND s1.sona='Visnap' AND s1.reg LIKE '__' JOIN sonad AS s2 ON s2.kid=k.kid AND s2.sona='Margot' AND s2.reg LIKE '__' JOIN sonad AS s3 ON s3.kid=k.kid AND s3.sona='1959-' AND s3.reg LIKE '__' JOIN sonad AS s4 ON s4.kid=k.kid AND s4.sona='toimetaja' AND s4.reg LIKE '__' ) AS k JOIN laadid AS l ON l.kid=k.kid) AS c;Table 'asko.jarjestus' doesn't exist