Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. ;WITH items AS (
  3. SELECT gl.id
  4. ,parent_id
  5. ,location_type_id
  6. ,gl.zip_code
  7. ,gl.name_clear
  8. ,gl.longitude
  9. ,gl.latitude
  10. ,name_clear AS Canton
  11. ,(select name_clear from GeoLocations where gl.touristic_01 = id) as T1
  12. ,(select name_clear from GeoLocations where gl.touristic_02 = id) as T2
  13. ,(select name_clear from GeoLocations where gl.touristic_03 = id) as T3
  14. FROM Geolocations gl WHERE gl.location_type_id = 5
  15. UNION ALL
  16. SELECT gl.id
  17. ,gl.parent_id
  18. ,gl.location_type_id
  19. ,gl.zip_code
  20. ,gl.name_clear
  21. ,gl.longitude
  22. ,gl.latitude
  23. ,Canton
  24. ,(select name_clear from GeoLocations where gl.touristic_01 = id) as T1
  25. ,(select name_clear from GeoLocations where gl.touristic_02 = id) as T2
  26. ,(select name_clear from GeoLocations where gl.touristic_03 = id) as T3
  27. FROM GeoLocations gl
  28. INNER JOIN items itms ON itms.Id = gl.parent_id
  29. )
  30. SELECT * FROM items WHERE location_type_id = 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement