I have a polygon layer with 3 fields (A, B and C). I want to create a copy and add as a virtual layer so I use CREATE VIRTUAL LAYER option but only want the first field.
So I use the expression Select A from "polygon layer"
But it doesnt work. What is wrong with my expression? The fields only contain string values. Do I need to specify geometry column?
This expression works Select * from "polygon layer
but takes all fields.
1 Answer 1
You forget the 4th field: geometry. It is not shown as a column, but it is there. If you do select * from layer
, then in fact you call select geometry, A, B, C from layer
.
So, if you want to load a copy of the original with only column 'A', you also have to call the geometry into the expression:
select geometry, A from layer