samedi 24 janvier 2015

Merging multiple tables using SQL in CartoDB


I have 5 separate tables in CartoDB each with a varying number of columns, but all containing these 4 columns (the_geom, name, type, unit_code). I want to merge them all into 1 new table and get rid of most of the columns. I figured out that UNION ALL will get rid of the columns I don't need in the end, but I can't see how to merge the tables using SQL. Whenever I try UNION ALL it doesn't want to work. I've also seen that sometimes I need to write UNION_ALL with the underscore to make it work? Here's my sample code:


SELECT the_geom, name, type, unit_code FROM points_of_interest UNION ALL SELECT the_geom, altname, descriptio, unitcode FROM arch_visitor_centers UNION ALL SELECT the_geom, name FROM arch_trailheads UNION ALL SELECT the_geom, bldg_name FROM arch_restrooms UNION ALL SELECT the_geom, name FROM arch_parking UNION ALL SELECT the_geom, name, FROM arch_campgrounds UNION ALL





Aucun commentaire:

Enregistrer un commentaire