What are the limitations in multiple WHERE conditions?

I tried this query but failed with three conditions like this:

match (s:Stem)-[:STEM_OF]->(w:Word) where not w.vocab ends with 'XX' or not w.vocab ends with 'YY' or not w.vocab ends with 'ZZ'
return w.vocab, s.vocab limit 100

But it works with where not(w.vocab ends with 'XX' or w.vocab ends with 'YY' or w.vocab ends with 'ZZ')

I tried this query but failed with three conditions

how so?
you got wrong/unexpected results?
or you got an error?

Also what version of Neo4j is in use here?

Hi Gigauser,

I think what goes wrong here is that the two statements

NOT Statement A OR NOT Statement B OR NOT Statement C

and

NOT (Statement A OR Statement B OR Statement C)

are NOT (!) the same.

It is

NOT Statement A OR NOT Statement B OR NOT Statement C = NOT (Statement A AND Statement B AND Statement C)

on the one hand and on the other hand

NOT Statement A AND NOT Statement B AND NOT Statement C = NOT (Statement A OR Statement B OR Statement C).

But these two lines are not the same!

What probably happens is that you first query just gives you all words and not just the ones that you were looking for, right? This is because all words do not end in all (!) three of your endings. Your second query gives you what you want because there you look for all words that do not end in any (!) of the endings.

For further reference: this is called the De Morgan's laws ( De Morgan's laws - Wikipedia)

Regards,
Elena

1 Like

Thank you for the tips!

God bless you and dana!