SELECT
netting_banners.banner_id,
netting_banners.type,
netting_banners.target,
netting_banners.status,
netting_banners.timestamp,
netting_banner_descriptions.banner,
netting_banner_descriptions.description,
netting_banner_descriptions.url,
netting_banner_images.banner_image_id,
netting_banners.group_id
FROM
netting_banners
LEFT JOIN netting_banner_descriptions ON netting_banner_descriptions.banner_id = netting_banners.banner_id
AND netting_banner_descriptions.lang_code = 'en'
LEFT JOIN netting_banner_images ON netting_banner_images.banner_id = netting_banners.banner_id
AND netting_banner_images.lang_code = 'en'
WHERE
1
AND (
netting_banners.type != 'G'
OR netting_banner_images.banner_image_id IS NOT NULL
)
AND netting_banners.banner_id IN (40)
AND netting_banners.status = 'A'
AND IF (
netting_banners.type not like 'abt__ut2',
'available',
IF (
netting_banners.type like 'abt__ut2'
AND (
netting_banners.abt__ut2_use_avail_period = 'N'
OR (
netting_banners.abt__ut2_use_avail_period = 'Y'
AND (
netting_banners.abt__ut2_avail_from = 0
OR netting_banners.abt__ut2_avail_from <= 1743825519
)
AND (
netting_banners.abt__ut2_avail_till = 0
OR netting_banners.abt__ut2_avail_till >= 1743825519
)
)
),
'available',
'not available'
)
) = 'available'
AND (
netting_banners.abt__ut2_usergroup_ids = ''
OR FIND_IN_SET(
0, netting_banners.abt__ut2_usergroup_ids
)
OR FIND_IN_SET(
1, netting_banners.abt__ut2_usergroup_ids
)
)
ORDER BY
netting_banner_descriptions.banner asc