Delete Query using filter for one specific user

Hi,

I am running following delete query to delete users except one user and below is the query.

DELETE WHERE {
			 ?user survey:role ?role ;
            
              survey:email ?email ;
			
              survey:password ?password ;
  			
              survey:status ?status ;
  		   
             survey:created_at ?created ;
  			
             survey:resetToken ?resetToken ;
   			
             survey:name ?name . 
   FILTER(?role != "xyy") .
   FILTER(?email != "andy@dff.com") .
   FILTER(?password !="$2a$10$OMheGK0hfrdGxa3kd11YZ.CfFxUrSDRZ/MzqT5W5RknTGRQ7oejQ2") .
    FILTER(?status != "ACTIVE") .
   FILTER(?created!= "232323") .
   FILTER(?resetToken!="1bf0c3f0-5367-11e7-8003-d71fb69058ba") .
  			 FILTER(?name!= "admin") }

and I am getting following error.

Parse error on line 19:
...ey:name ?name .    FILTER(?role != "GDP
----------------------^
Expecting 'IRIREF', 'PNAME_NS', 'VAR', '(', '}', 'INTEGER', 'GRAPH', 'NIL', '[', 'BLANK_NODE_LABEL', 'ANON', 'DECIMAL', 'DOUBLE', 'true', 'false', 'STRING_LITERAL1', 'STRING_LITERAL2', 'STRING_LITERAL_LONG1', 'STRING_LITERAL_LONG2', 'INTEGER_POSITIVE', 'DECIMAL_POSITIVE', 'DOUBLE_POSITIVE', 'INTEGER_NEGATIVE', 'DECIMAL_NEGATIVE', 'DOUBLE_NEGATIVE', 'PNAME_LN', got 'FILTER'

Please help me to figure out how could I put the filter for one specific user which I dont want to delete.

Thanks in Advance,
Yashpal

The FILTER needs to be in a WHERE clause

1 Like

THanks for your valuable comment, issue resolved.

I’m glad that helped but now I’m looking at it the response might be a bit misleading so I’ll add some clarification for anyone coming across this in the future. The DELETE WHERE is a shortcut and doesn’t allow for filters. Specifically the grammar is DELETE WHERE QuadPattern where the full delete grammar (abbreviated) is DELETE QuadPattern WHERE GroupGraphPattern. The QuadPattern doesn’t allow for filters where the GroupGraphPattern does so if you want to use filters you can’t use the shortcut.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.