Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;WITH items AS (
- SELECT gl.id
- ,parent_id
- ,location_type_id
- ,gl.zip_code
- ,gl.name_clear
- ,gl.longitude
- ,gl.latitude
- ,name_clear AS Canton
- ,(select name_clear from GeoLocations where gl.touristic_01 = id) as T1
- ,(select name_clear from GeoLocations where gl.touristic_02 = id) as T2
- ,(select name_clear from GeoLocations where gl.touristic_03 = id) as T3
- FROM Geolocations gl WHERE gl.location_type_id = 5
- UNION ALL
- SELECT gl.id
- ,gl.parent_id
- ,gl.location_type_id
- ,gl.zip_code
- ,gl.name_clear
- ,gl.longitude
- ,gl.latitude
- ,Canton
- ,(select name_clear from GeoLocations where gl.touristic_01 = id) as T1
- ,(select name_clear from GeoLocations where gl.touristic_02 = id) as T2
- ,(select name_clear from GeoLocations where gl.touristic_03 = id) as T3
- FROM GeoLocations gl
- INNER JOIN items itms ON itms.Id = gl.parent_id
- )
- SELECT * FROM items WHERE location_type_id = 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement