Hello everyone, welcome to our GIS tutorial. Today, we are going to learn about query in QGIS. I am going to show you how to use the Update SQL Layer menu on QGIS. When you open a layer in the QGIS canvas, and then right-click the layer, you will see the Update SQL layer menu. This menu is very useful when we need to select some data using SQL query syntax. On the following example, I have a contour layer which has some attributes columns.
And the following is the contour layer in QGIS canvas
I will show you how to select some data using the SQL query. For example, I will select contour lines which have the elevation more than 200 meters. You can use your own data for practice.
Right click the layer and then click Update SQL Layer. It will open up the query window where we can type our query. By default, there will be a line of SQL syntax which shows something like this:
SELECT * FROM "Contour_50m"
Where Contour_50m is the name of my layer. Now let’s try to modify the SQL syntax a little bit into this one
SELECT * FROM "Contour_50m" where elevation = 200
Now hit Execute. You may notice that the table show the result of the query. To see the result in QGIS canvas, click Update button. Watch the following video