Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying different queries in the Query Builder. Is there a way to comment the query? I tried with

/* */



without success :

An error occurred when executing the query. The data provider said: OGR[3] error 1: SQL Expression Parsing Error: syntax error


  • I have made a feature request of this question:

  • @Bernd V. observed that expressions are evaluated differently according to the format of the vector (see the [help] button in the Query builder for more information)

share|improve this question
Welcome to GIS! Unless I'm mistaken, I don't think you can comment queries in the Query Builder. – Joseph Jul 17 '14 at 12:18
Is there an other way to build queries then (and comment them as required ?) (Thx for editing, it looks much better) – nebi Jul 17 '14 at 12:48
up vote 5 down vote accepted

You can build queries by using the Query Builder or an alternative is to use the Expression string builder (Layer Properties > Style > select Rule-based > add a rule > insert your command in the Filter box or click the '...' button to bring up the string builder interface.

In both cases, I do not think QGIS supports the comments function when creating expressions for filters/queries:

share|improve this answer
True, with this way you can save your rules and import / export them ... But it's not as quick as commenting with some symbol at the beginning of the line. Copy / paste in the query Builder is tedious – nebi Jul 17 '14 at 13:58
@nebi, you could always send a request for this to be implemented in future updates. – Joseph Jul 17 '14 at 14:11
Yes, I want to do it – nebi Jul 17 '14 at 14:12

Just as an update to reflect the fast development in QGIS:

In QGIS 2.8.2 (I don't know when it was introduced), commenting in expressions now seems to work!

Using -- for one-line comments and /* ... */ for multi-line comments

turnes the letters to a green color in the expression builder window and they seem indeed to be commented out!

Thanks to the developers!

share|improve this answer
Awesome! I don't have QGIS 2.8.2 to test but it is mentioned here so I believe you :) In which case, your answer should be accepted! – Joseph Jun 2 '15 at 12:18
and @Joseph: are you sure you're in the Query Builder? I can't reproduce it. It turns the letters to green but it still doesn't work (2.8.2-Wien). – nebi Jun 4 '15 at 8:11
@nebi - I also cannot reproduce it in the Query Builder (also installed 2.8.2 Wien). Only seems to work in the Field Calculator. Have you opened a ticket (feature request) for this? – Joseph Jun 4 '15 at 11:32
didn't test it beforehand in the Query Builder (sorry) but with rule based rendering expressions etc, cause I hardly ever use that thing. But here it works as well. Am on Linux Mint, maybe there is a difference/bug in Windows? – Bernd V. Jun 4 '15 at 12:22
Ha! Seems I found the difference. I was using it successfully with a Spatialite-Layer. Now I tested it with a ESRI-Shape ... and it fails! – Bernd V. Jun 4 '15 at 12:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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