There are several ways to solve your problem, one involving other field-format and four avoiding the problematic or
operator:
- Use numbers, not strings - the solution closest to what you have
- Use
like
functions - the easiest an most elegant solution
- Use
case
condition - the classic solution for such combined conditions
- Use
if
condition - works, but a bit more complicated
- Use
in
operator -tribute to @jdavid05's comment
In detail:
Simply leave away the single quotes: as you don't have texts, but numbers, they are not necessary - thus not "veg_actu1"='600000'
, but "veg_actu1"=600000
:
"veg_actu1" = 600000 or "veg_actu1" = 601000 or "veg_actu1" = 601100 or "veg_actu1" = 602000 or "veg_actu1" = 603000

- function
like
, used with wildcards (underscores: _
)
"veg_actu1" like '60____'
case
-condition:
CASE
WHEN "veg_actu1" = '600000' then 1
WHEN "veg_actu1" = '601000' then 1
WHEN "veg_actu1" = '602000' then 1
WHEN "veg_actu1" = '601100' then 1
WHEN "veg_actu1" = '603000' then 1
else 0
end
if
-condition:
if (
"veg_actu1" = '601100',1,
if (
"veg_actu1" = '600000', 1,
if (
"veg_actu1" = '601000', 1,
if (
"veg_actu1" = '602000', 1,
if (
"veg_actu1" = '603000',1,0
)
)
)
)
)
in
-operator (as proposed in the comment by user @jdavid05)
"veg_actu1" IN ('601100','600000','601000','602000','603000')
Background
After some testing, it turns out that the order of the original expression you used plays a role:
This expression returns styling for some, but not all polygons:
"veg_actu1" = '600000' or "veg_actu1" = '601000' or "veg_actu1" = '602000' or "veg_actu1" = '601100' or "veg_actu1" = '603000'
But with this expression, no polygon at all gets styled:
"veg_actu1" = '601100' or "veg_actu1" = '600000' or "veg_actu1" = '601000' or "veg_actu1" = '602000' or "veg_actu1" = '603000'
I think the problem is linking several or
opeartors one after the other. The help says:
Operator OR: Returns 1 when condition a and b are true.
The examples in the help are like this:
- 4 = 2+2 OR 1 = 1 → 1
- 4 = 2+2 OR 1 = 2 → 1
- 4 = 2 OR 1 = 2 → 0
But you have not something like A OR B
, but A OR B OR C OR D OR E
. This seems to be problematic, at least when used with strings.
regexp_match(veg_actu1, '(6)')
will return 1 here). Thecase when
is closer to the equality comparison though.