1

I am experiencing difficulties with SQL syntax in a Virtual Layer. I can do the simplest query form such as:

SELECT *
FROM mytable

and this displays on my canvas.

However, if I try to name fields in my table such as:

SELECT field1, field2
FROM mytable

this doesn't create an error but does not display on my canvas.

Can anyone offer suggestions, please? I have tried it on several layers.

3

For virtual layers, the actual geometry of the features are in a column named geometry.

In your first query when you select all columns, you are implicitly selecting the geometry column. That's why you can see the features on the canvas.

In the second query, you are only selecting non-spatial columns (field1, field2 etc.) and they show up as a table. To fix that, update your query like below

SELECT field1, field2, geometry
FROM mytable
  • Thank you for your help. I hadn't realised that a geometry field is required in the syntax. This solves my problem. Well done. – Colin Mazengarb Jul 17 at 11:15

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.