mapbox / mapbox-studio-classic

https://www.mapbox.com/mapbox-studio/
BSD 3-Clause "New" or "Revised" License
1.14k stars 229 forks source link

UNION ALL example broken #1189

Open lxbarth opened 9 years ago

lxbarth commented 9 years ago

This example is broken, the () shouldn't be around each select statement but the entire subquery. @ajashton - am I missing something here?

screen shot 2015-02-14 at 9 43 39 pm

Better:

( SELECT wkb_geometry, area
  FROM ponds
  WHERE z(!scale_denominator!) >= 10
    AND wkb_geometry && !bbox!
UNION ALL
  SELECT wkb_geometry, area
  FROM lakes
  WHERE z(!scale_denominator!) >= 6
    AND wkb_geometry && !bbox!
UNION ALL
  SELECT wkb_geometry, area
  FROM oceans
  WHERE wkb_geometry && !bbox!
) AS data
ajashton commented 9 years ago

Ya the current example is wrong. Your fix is correct, but original intention might have been something like below which is what the user would have to do if they want to add an ORDER BY to any of the subqueries (a common need).

((SELECT wkb_geometry, area
  FROM ponds
  WHERE z(!scale_denominator!) >= 10
    AND wkb_geometry && !bbox!
) UNION ALL (
  SELECT wkb_geometry, area
  FROM lakes
  WHERE z(!scale_denominator!) >= 6
    AND wkb_geometry && !bbox!
) UNION ALL (
  SELECT wkb_geometry, area
  FROM oceans
  WHERE wkb_geometry && !bbox!
))AS data