32

Usually I can find everything I need already on SO but not this time. I'm looking for a very simple way to exclude labels, for example (pseudo code):

match (n) where n not in (Label1, Label2) return n

Sorry about crappy query. In short I have labels x,y,z and I want to return all of them apart from z.

Thnx!

Aryan G
  • 1,281
  • 10
  • 30
  • 51
Ed Baker
  • 643
  • 1
  • 6
  • 16

2 Answers2

67

This should do it:

MATCH (n)
WHERE NOT n:Label1 AND NOT n:Label2
RETURN n;
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Oskar Hane
  • 1,824
  • 13
  • 8
0

If you have a long list of labels you want to exclude, I find this syntax to be helpful:

match (n)
where not labels(n) in [['label1'],['label2'],['label3']]
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38