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 laadid AS l ON l.kid=k.kid AND l.laad IN ('muusika') JOIN register AS reg_formaat ON reg_formaat.kid=k.kid AND reg_formaat.register = 'lipud' AND reg_formaat.sisu IN ('evaljaanne')) AS k JOIN laadid AS l ON l.kid=k.kid AND l.laad IN ('muusika') JOIN register AS reg_formaat ON reg_formaat.kid=k.kid AND reg_formaat.register = 'lipud' AND reg_formaat.sisu IN ('evaljaanne')) AS c;Table 'asko.jarjestus' doesn't exist