5

I'm trying to use the Data Defined symbology in QGIS ver 2.2. Some of my data has single quotes/apostrophes.

Since the string must use single quotes, is there an escape option I can use for the field calculator or for the data defined settings field?

So, I'm trying to use something like this:

CASE
WHEN "NAME" = 'WILSON'S' THEN '0,75,224'
END

How do you build an expression around a string that may have a single quote or apostrophe?

Thanks. QGIS Valmiera 2.2 Windows 7 - 32 bit

8

Using the escaping by simply doubling the single quote works for me:

CASE
WHEN "NAME" = 'WILSON''S' THEN '0,75,224'
END

Double quotes in the field value don't need escaping:

CASE
WHEN "NAME" = 'WILSON"S' THEN '0,75,224'
END

and I'm not sure if they are allowed in field names. Surely not in shapefiles.

Works at least on Windows.

| improve this answer | |

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.