2

I am having problem creating a query. I have a data map, which is organised in areas with codes (which in turn correspond to funding oportunities). I am trying to select for each code a layer. Up until then, its pretty straight forward.

The problem arises when I want to combine two codes. Through the Attribute Table, I select features using a expression,from the FIELDS AND VALUES, for example

"BINDUNG" LIKE '%11Z%'


However when I try to use

"BINDUNG" Like '%11Z%' AND LIKE '%812%'

or

"BINDUNG" Like '%11Z%' AND NOT LIKE '%812%'

it simply doesn´t work.

Is there another expression I can use?

1 Answer 1

4

You cannot simply chain the operators ('LIKE'), you need to repeat the field relation ("BINDUNG"):


Also I need to add: if you want to select features having one of both attributes you need to use the OR operator. The AND operator combines both expression into one condition so that only those features would be selected whose attributes match both expressions combined.

"BINDUNG" LIKE '%11Z%' OR "BINDUNG" LIKE '%812%'

would select features with either matching %11Z% or %812%.

"BINDUNG" LIKE '%11Z%' OR "BINDUNG" NOT LIKE '%812%'

would select features with matching %11Z% and those not matching %812%.

"BINDUNG" LIKE '%11Z%' AND "BINDUNG" NOT LIKE '%812%'

would select features matching %11Z% and not %812% at the same time (e.g. 00011Z000 would work, 00011Z000812000 would not).


Also, I think you can use

"BINDUNG" IN ('%11Z%', '%812%')

in the first case alternatively, but I'm not 100% sure if the % wildcard is valid for IN. Try it if you want.

No. IN requires exact matching (e.g. "BINDUNG IN ('00011Z000', '000812000')).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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