4

I have a SpatiaLite database with some multipolygon layers loaded.

What I would like to do is to merge (not dissolve) 2 layers into 1. Both layers have the same SRID and same field name (they are a result of the same algorithm).

I'm looking for a SpatiaLite funcion that does the same thing of QGIS -> Union.

Is there a simple comand to do that?


My solution, using @Alexandre's suggestions:

CREATE TABLE merged AS SELECT * FROM layer1 UNION ALL SELECT * FROM layer2; SELECT RecoverGeometryColumn('merged', 'Geometry', 32632, 'MULTIPOLYGON', 'XY'); 

2 Answers 2

5

If you use DB Manager, you can use plain SQL to union two tables. Something like this:

SELECT field1, field2 FROM my_table_1 UNION ALL SELECT field1, field2 FROM my_table_2 

Notice that the fields must match in both tables in terms of data type, but they do not need to have the same name.

0
0

for show geometry in Qgis Canvas you need call a colum named geometry

for the example:

SELECT field1, field2, geometry FROM my_table_1 UNION ALL SELECT field1, field2, geometry FROM my_table_2 

with geometry colum qgis can show on screen

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.