SELECT
COUNT(
DISTINCT(cscart_companies.company_id)
)
FROM
cscart_companies
LEFT JOIN cscart_company_descriptions ON cscart_company_descriptions.company_id = cscart_companies.company_id
AND cscart_company_descriptions.lang_code = 'tr'
LEFT JOIN cscart_absolute_rating AS absolute_rating ON absolute_rating.object_id = cscart_companies.company_id
AND absolute_rating.object_type = 'company'
LEFT JOIN cscart_vendor_plan_descriptions ON cscart_companies.plan_id = cscart_vendor_plan_descriptions.plan_id
AND cscart_vendor_plan_descriptions.lang_code = 'tr'
LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = cscart_companies.company_id
AND cscart_seo_names.type = 'm'
AND cscart_seo_names.dispatch = ''
AND cscart_seo_names.lang_code = 'tr'
LEFT JOIN cscart_discussion ON cscart_discussion.object_id = cscart_companies.company_id
AND cscart_discussion.object_type = 'M'
LEFT JOIN cscart_discussion_posts ON cscart_discussion_posts.thread_id = cscart_discussion.thread_id
AND cscart_discussion_posts.status = 'A'
LEFT JOIN cscart_discussion_rating ON cscart_discussion.thread_id = cscart_discussion_rating.thread_id
AND cscart_discussion_rating.post_id = cscart_discussion_posts.post_id
WHERE
1
AND cscart_companies.status = 'A'
AND cscart_companies.company_id IN (3, 4)