Difference between quotation marks ('single' vs “double”) in QGIS
up vote
5
down vote
favorite
I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double").
I know something about the quotation marks and the way they are applied in Python scripting (i.e. comments, strings etc.).
There are even some related questions:
- Single quotes vs. double quotes in Python [closed]
- Is there any difference between “string” and 'string' in Python? [duplicate]
Nevertheless, I would like to clarify the details regarding the quotation marks ('single' vs "double") in the scope of QGIS.
For instance, if I type something in the Expression dialogue I will have a different output.
"something", it is written as

The Output is NULL.
'something', it is shown as

The output is 'something' as a string.
So, my questions are:
- What is the syntax/meaningful difference between quotation marks ('single' vs "double") in QGIS?
- Are there any other circumstances when other types of quotation marks are used in QGIS, for instance, triple quotation marks as in Python?
qgis expression syntax
add a comment |
up vote
5
down vote
favorite
I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double").
I know something about the quotation marks and the way they are applied in Python scripting (i.e. comments, strings etc.).
There are even some related questions:
- Single quotes vs. double quotes in Python [closed]
- Is there any difference between “string” and 'string' in Python? [duplicate]
Nevertheless, I would like to clarify the details regarding the quotation marks ('single' vs "double") in the scope of QGIS.
For instance, if I type something in the Expression dialogue I will have a different output.
"something", it is written as

The Output is NULL.
'something', it is shown as

The output is 'something' as a string.
So, my questions are:
- What is the syntax/meaningful difference between quotation marks ('single' vs "double") in QGIS?
- Are there any other circumstances when other types of quotation marks are used in QGIS, for instance, triple quotation marks as in Python?
qgis expression syntax
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double").
I know something about the quotation marks and the way they are applied in Python scripting (i.e. comments, strings etc.).
There are even some related questions:
- Single quotes vs. double quotes in Python [closed]
- Is there any difference between “string” and 'string' in Python? [duplicate]
Nevertheless, I would like to clarify the details regarding the quotation marks ('single' vs "double") in the scope of QGIS.
For instance, if I type something in the Expression dialogue I will have a different output.
"something", it is written as

The Output is NULL.
'something', it is shown as

The output is 'something' as a string.
So, my questions are:
- What is the syntax/meaningful difference between quotation marks ('single' vs "double") in QGIS?
- Are there any other circumstances when other types of quotation marks are used in QGIS, for instance, triple quotation marks as in Python?
qgis expression syntax
I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double").
I know something about the quotation marks and the way they are applied in Python scripting (i.e. comments, strings etc.).
There are even some related questions:
- Single quotes vs. double quotes in Python [closed]
- Is there any difference between “string” and 'string' in Python? [duplicate]
Nevertheless, I would like to clarify the details regarding the quotation marks ('single' vs "double") in the scope of QGIS.
For instance, if I type something in the Expression dialogue I will have a different output.
"something", it is written as

The Output is NULL.
'something', it is shown as

The output is 'something' as a string.
So, my questions are:
- What is the syntax/meaningful difference between quotation marks ('single' vs "double") in QGIS?
- Are there any other circumstances when other types of quotation marks are used in QGIS, for instance, triple quotation marks as in Python?
qgis expression syntax
qgis expression syntax
edited Nov 6 at 18:24
underdark♦
67.1k13174336
67.1k13174336
asked Nov 6 at 11:33
Taras
1,4561521
1,4561521
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
11
down vote
accepted
Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use"name" = 'Fred'
– Spacedman
Nov 6 at 19:31
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
add a comment |
up vote
8
down vote
Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above
add a comment |
up vote
5
down vote
Double marks refer to columns in the attribute table, single marks to a string value. E.g. CASE WHEN "something" > 100 THEN 'a lot' ELSE 'not so much' checks the size of integer values in your column and adds a string to fields in the attribute table based on that size.
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbersWHEN "something" > 100?
– user30184
Nov 6 at 17:10
1
Actually'100'really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.
– Erik
Nov 7 at 8:05
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use"name" = 'Fred'
– Spacedman
Nov 6 at 19:31
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
add a comment |
up vote
11
down vote
accepted
Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use"name" = 'Fred'
– Spacedman
Nov 6 at 19:31
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
add a comment |
up vote
11
down vote
accepted
up vote
11
down vote
accepted
Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.
Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.
answered Nov 6 at 11:35
Ian Turton♦
46.5k545108
46.5k545108
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use"name" = 'Fred'
– Spacedman
Nov 6 at 19:31
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
add a comment |
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use"name" = 'Fred'
– Spacedman
Nov 6 at 19:31
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
3
3
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use
"name" = 'Fred'– Spacedman
Nov 6 at 19:31
My mnemonic for this is "Single for Strings, Double for Data". So to compare a data field with a string value you'd use
"name" = 'Fred'– Spacedman
Nov 6 at 19:31
1
1
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
Great mnemonic tip. Thanks a lot @Spacedman!
– Pescariz
Nov 7 at 9:01
add a comment |
up vote
8
down vote
Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above
add a comment |
up vote
8
down vote
Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above
add a comment |
up vote
8
down vote
up vote
8
down vote
Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above
Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above
answered Nov 6 at 11:46
ahmadhanb
20.5k31847
20.5k31847
add a comment |
add a comment |
up vote
5
down vote
Double marks refer to columns in the attribute table, single marks to a string value. E.g. CASE WHEN "something" > 100 THEN 'a lot' ELSE 'not so much' checks the size of integer values in your column and adds a string to fields in the attribute table based on that size.
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbersWHEN "something" > 100?
– user30184
Nov 6 at 17:10
1
Actually'100'really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.
– Erik
Nov 7 at 8:05
add a comment |
up vote
5
down vote
Double marks refer to columns in the attribute table, single marks to a string value. E.g. CASE WHEN "something" > 100 THEN 'a lot' ELSE 'not so much' checks the size of integer values in your column and adds a string to fields in the attribute table based on that size.
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbersWHEN "something" > 100?
– user30184
Nov 6 at 17:10
1
Actually'100'really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.
– Erik
Nov 7 at 8:05
add a comment |
up vote
5
down vote
up vote
5
down vote
Double marks refer to columns in the attribute table, single marks to a string value. E.g. CASE WHEN "something" > 100 THEN 'a lot' ELSE 'not so much' checks the size of integer values in your column and adds a string to fields in the attribute table based on that size.
Double marks refer to columns in the attribute table, single marks to a string value. E.g. CASE WHEN "something" > 100 THEN 'a lot' ELSE 'not so much' checks the size of integer values in your column and adds a string to fields in the attribute table based on that size.
edited Nov 7 at 8:06
answered Nov 6 at 11:37
Erik
2,48418
2,48418
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbersWHEN "something" > 100?
– user30184
Nov 6 at 17:10
1
Actually'100'really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.
– Erik
Nov 7 at 8:05
add a comment |
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbersWHEN "something" > 100?
– user30184
Nov 6 at 17:10
1
Actually'100'really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.
– Erik
Nov 7 at 8:05
1
1
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
Does this mean that the value of an attribute "something" is bigger than string '100'?
– user30184
Nov 6 at 14:49
1
1
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
If the value of a field in column "something" is bigger than 100, then I write "a lot" into a new column, else the other text is written.
– Erik
Nov 6 at 15:13
3
3
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
Is '100' between single quotes because it represents the number of characters from string (instead of an integer values) due to "something" column being of type text?
– Andre Silva
Nov 6 at 15:39
1
1
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbers
WHEN "something" > 100?– user30184
Nov 6 at 17:10
I asked because I do not know the syntax that QGIS is using. In databases '100' means a string and then '101'>'100' but also '99'>'100' because 9 comes after 1 in alphanumeric order. Does QGIS make difference and is it possible to compare by numbers
WHEN "something" > 100?– user30184
Nov 6 at 17:10
1
1
Actually
'100' really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.– Erik
Nov 7 at 8:05
Actually
'100' really means a string, sorry, gonna edit it. Comparison of numbers is possible, yes.– Erik
Nov 7 at 8:05
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f301566%2fdifference-between-quotation-marks-single-vs-double-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password