user7755452
user7755452

Reputation:

how to write a select cypher inside 'IN' clause in neo4j

I want to add a sub query inside IN Clause cipher in neo4j as shown in below SQL code

update Contact set LookedupStatus = 1 where ContactId IN (SELECT 
ContactId  FROM Contact where 
((FacebookUrl IS NOT NULL) or (TwitterUrl IS NOT NULL) or (LinkedinUrl 
IS NOT NULL))
and
((FacebookUrl != '') or (TwitterUrl != '') or (LinkedinUrl != '')))

Please anyone help how to convert the above SQL code to neo4j cipher code

Upvotes: 0

Views: 175

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

Assuming you have :Contact nodes, and all these fields are modeled as properties of your :Contact nodes, that should be fairly straight forward.

Cypher has no need to deal with this using subqueries, it's enough to just match, filter, and set the properties on the filtered nodes.

// first match on :Contact nodes with the required properties
MATCH (c:Contact)
WHERE ((c.FacebookUrl IS NOT NULL) or (c.TwitterUrl IS NOT NULL) or (c.LinkedinUrl IS NOT NULL))
and
((c.FacebookUrl <> '') or (c.TwitterUrl <> '') or (c.LinkedinUrl <> ''))
// update status
SET c.LookedupStatus = 1

Upvotes: 1

Related Questions