Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- AN.*,
- CASE
- WHEN AN.area_type ilike 'city' THEN CT.city
- WHEN AN.area_type ilike 'state' THEN ST.State
- WHEN AN.area_type ilike 'country' THEN CN.country
- WHEN AN.area_type ilike 'region' THEN RJ.region
- END as area_name
- FROM
- area_notifications AN
- LEFT JOIN
- cities CT
- ON
- CT.city_id = AN.area_id
- LEFT JOIN
- states ST
- ON
- ST.state_id = AN.area_id
- LEFT JOIN
- countries CN
- ON
- CN.country_id = AN.area_id
- LEFT JOIN
- regions RJ
- ON
- RJ.region_id = AN.area_id
- WHERE
- AN.is_deleted = FALSE
Add Comment
Please, Sign In to add comment