title: Neo4j Cypher query deleting a node and all children nodes and relationships
body: <p>This is part of my Neo4j code in Cypher: </p>
  
  <pre><code>CREATE 
  (search{id : '0', title : 'Begin Search'}),
  (telephone { id : '2' , title : 'Telephone' }),
  (tablet { id : '1' , title : 'Tablet' }),
  (printer { id : '3' , title : 'Printer' }),
  (scanner { id : '4' , title : 'Scanner' }),
  (laptop { id : '5' , title : 'Laptop' }),
  (pc { id : '6' , title : 'Personal Computer' }),
  (monitor { id : '7' , title : 'Monitor' }),
  
  (galaxykids7wifi { id : '100' , model : ' Galaxy Tab 3 Kids 7.0 wi-fi', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android Jelly Bean 4.1', memory : '8 Gb' , screen : '7 inches ', wieght : '302 g', dimensions : '111.1*188*9.9 mm' , battery : '4000 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }),
  (galaxytab310wifi3g { id : '101' , model : ' Galaxy Tab 3 10.1 wi-fi + 3 G', brand : 'Samsung', processor : 'Dual-Core Intel Atom Processor', network : 'Android 2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '10.1 inches ', wieght : '512 g', dimensions : '176.1*243,1*7.45 mm' , battery : '6800 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }),
  (galaxytab310wifi { id : '102' , model : ' Galaxy Tab 3 10.1 wi-fi', brand : 'Samsung', processor : 'Dual-Core Intel Atom Processor', network : 'Android 2.2', memory : '16 Gb',memory1 : '32 Gb' , screen : '10.1 inches ', wieght : '510 g', dimensions : '176.1*243,1*7.45 mm' , battery : '6800 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }), 
  (galaxytab38wifi3g { id : '103' , model : ' Galaxy Tab 3 8.0 wi-fi + 3 G', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android JB 4.2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '8 inches ', wieght : '316 g', dimensions : '123.8*209.8*7.4 mm' , battery : '4450 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1.5 Gb', kamera : '5 Mpix'}),
  (galaxytab38wifi { id : '104' , model : ' Galaxy Tab 3 8.0 wi-fi', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android JB 4.2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '8 inches ', wieght : '314 g', dimensions : '204.8*123.8*7.4 mm' , battery : '4450 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1.5 Gb', kamera : '5 Mpix'}),
  
  (search)&lt;-[:TYPE]-(tablet),
  (search)&lt;-[:TYPE]-(telephone),
  (search)&lt;-[:TYPE]-(printer),
  (search)&lt;-[:TYPE]-(scanner),
  (search)&lt;-[:TYPE]-(laptop),
  (search)&lt;-[:TYPE]-(pc),
  (search)&lt;-[:TYPE]-(monitor),
  
  (tablet)&lt;-[:TYPE]-(galaxykids7wifi),
  (tablet)&lt;-[:TYPE] -(galaxytab310wifi3g),
  (tablet)&lt;-[:TYPE]-(galaxytab310wifi),
  (tablet)&lt;-[:TYPE]-(galaxytab38wifi3g),
  (tablet)&lt;-[:TYPE]-(galaxytab38wifi)
  </code></pre>
  
  <p>I'm trying to delete lets say node 1 with all children nodes attached to it (in this case the products) and relationships shared between them. I've tried numerous solutions people say work over various web pages, but i keep on getting this </p>
  
  <pre><code>'STATEMENT_EXECUTION_ERROR' : 'Node with id 1' 
  </code></pre>
  
  <p>I'm guessing the problem is that the query can't read where node with <code>id : 1</code> is, but that makes no sense. Please help me if possible.</p>
  
  <p>Queries like this one don't work: </p>
  
  <pre><code>start n=node(1) 
  match n-[*]-x 
  WITH x 
  MATCH x-[r]-() delete x,r
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>The two answers below don't work either. I'm running Neo4j 2.0.0 - M06</p>
  
  <p>1)</p>
  
  <pre><code>MATCH (n {id:'1'})&lt;-[r]-x-[ss*0..]-y
  WHERE NOT r IN ss  
  OPTIONAL MATCH n-[t]-&gt;()
  FOREACH (s IN ss | DELETE s)
  DELETE r,y,t,n
  
  Error: Invalid input 'P' : expected 'r/R'
     "OPTIONAL MATCH n-[t]-&gt;()"
       ^
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>match (n {id : '1'})
  optional match n-[r]-x
  delete r,x
  
  Invalid input 'o': expected whitespace, comment, a relationship patter, .....
  "optional match n-[r]-x"
   ^
  </code></pre>