SELECT
cscart_banners.banner_id,
cscart_banners.type,
cscart_banners.target,
cscart_banners.status,
cscart_banners.timestamp,
cscart_banner_descriptions.banner,
cscart_banner_descriptions.description,
cscart_banner_descriptions.url,
cscart_banner_images.banner_image_id
FROM
cscart_banners
LEFT JOIN cscart_banner_descriptions ON cscart_banner_descriptions.banner_id = cscart_banners.banner_id
AND cscart_banner_descriptions.lang_code = 'ar'
LEFT JOIN cscart_banner_images ON cscart_banner_images.banner_id = cscart_banners.banner_id
AND cscart_banner_images.lang_code = 'ar'
WHERE
1
AND (
cscart_banners.type != 'G'
OR cscart_banner_images.banner_image_id IS NOT NULL
)
AND cscart_banners.banner_id IN (6)
AND cscart_banners.status = 'A'
ORDER BY
cscart_banner_descriptions.banner asc