0

I have two tables (in CartoDB/PostGIS) that are from two tiger shapefiles that have the exact same attributes, just in different counties. I want to combine them in to a single table, just appending the data from one to the other. What is the SQL call to do that?

1

Presuming you have two datyasets with the same attributes:

test_points1

enter image description here

and test_points2

enter image description here

you can combine them like this:

CREATE TABLE combined AS( 
    SELECT id, city, geom FROM test_points1
    UNION 
    SELECT id, city, geom FROM test_points2)

and the result is the combined table:

enter image description here

  • 1
    The UNION keyword will check to ensure that all records are unique (which is expensive). If you don't want then de-duped in the process, use UNION ALL instead. – Paul Ramsey Feb 27 '14 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.