Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- profile.id as profile_id,
- profile.name as profile_name,
- location_id.value as location_id,
- if( location.country_id = location.id, null, area.name ) as area_name,
- region.name as region_name,
- if( location.country_id = location.id, area.name, country.name ) as country_name
- from
- b_sale_user_props profile
- inner join b_sale_person_type person on person.active='Y'
- inner join b_sale_order_props prop on prop.code='location' and prop.person_type_id=person.id
- inner join b_sale_user_props_value location_id on location_id.user_props_id=profile.ID and location_id.order_props_id=prop.id
- inner join b_sale_location location on location.id=location_id.value
- inner join b_sale_loc_name area on area.language_id='en' and area.location_id=location.id
- left join b_sale_loc_name region on region.language_id='en' and region.location_id=location.region_id
- left join b_sale_loc_name country on country.language_id='en' and country.location_id=location.country_id and location.country_id != location.id
- where
- profile.user_id=24053
- and person.lid='s1'
- order by
- country_name asc,
- region_name asc,
- area_name asc
Advertisement
Add Comment
Please, Sign In to add comment