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 = 'en'
LEFT JOIN cscart_banner_images ON cscart_banner_images.banner_id = cscart_banners.banner_id
AND cscart_banner_images.lang_code = 'en'
WHERE
1
AND (
cscart_banners.type != 'G'
OR cscart_banner_images.banner_image_id IS NOT NULL
)
AND cscart_banners.banner_id IN (27)
AND cscart_banners.status = 'A'
AND IF(
cscart_banners.from_date, cscart_banners.from_date <= 1732141739,
1
)
AND IF(
cscart_banners.to_date, cscart_banners.to_date >= 1732141739,
1
)
AND (
cscart_banners.usergroup_ids = ''
OR FIND_IN_SET(0, cscart_banners.usergroup_ids)
OR FIND_IN_SET(1, cscart_banners.usergroup_ids)
)
AND IF (
cscart_banners.type not like 'abt__ut2',
'available',
IF (
cscart_banners.type like 'abt__ut2'
AND (
cscart_banners.abt__ut2_use_avail_period = 'N'
OR (
cscart_banners.abt__ut2_use_avail_period = 'Y'
AND (
cscart_banners.abt__ut2_avail_from = 0
OR cscart_banners.abt__ut2_avail_from <= 1732141739
)
AND (
cscart_banners.abt__ut2_avail_till = 0
OR cscart_banners.abt__ut2_avail_till >= 1732141739
)
)
),
'available',
'not available'
)
) = 'available'
AND (
cscart_banners.abt__ut2_usergroup_ids = ''
OR FIND_IN_SET(
0, cscart_banners.abt__ut2_usergroup_ids
)
OR FIND_IN_SET(
1, cscart_banners.abt__ut2_usergroup_ids
)
)
ORDER BY
cscart_banner_descriptions.banner asc