# Check if node exists - proposal for a new APOC-function

**URL:** <https://community.neo4j.com/t/check-if-node-exists-proposal-for-a-new-apoc-function/32094>\
**Category:** Procedures & APOC\
**Created:** [January 15, 2021, 7:38am UTC](https://community.neo4j.com/t/check-if-node-exists-proposal-for-a-new-apoc-function/32094 "2021-01-15T07:38:26Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [January 18, 2021, 5:59pm UTC](https://community.neo4j.com/t/check-if-node-exists-proposal-for-a-new-apoc-function/32094/9 "2021-01-18T17:59:21Z")

</div>

@michael.hunger

Unfortunately, I'm at the stage of where Cypher is like Legos: I can build fragments but I can't always build an entire structure that I want. I'm beginning to understand subqueries (which I believe don't get enough emphasis) but I'm not fully there... I don't understand why I'm not allowed to put certain pieces together in certain ways that I would have thought possible.

I naively tried this:

`RETURN exists { MATCH (u:User {name: "abc@xyz.at"}) }`

but I got this error msg...

> The EXISTS subclause is not valid inside a WITH or RETURN clause. (line 1, column 9 (offset: 8))  
> "RETURN exists {MATCH (u:User {name: "abc@xyz.at"})}"  
> ^

I do see the exist subquery documentation, but it doesn't match up with what I (and the OP) would like to do.

> **[Subqueries - Developer Guides](https://neo4j.com/developer/cypher/subqueries/)**
>
> Building on the previous Cypher guides, this guide shows how to write subqueries. Upon finishing this guide, you should be able to write and understand queries using this capability.

I also tried this: I'd like to do an existing test within `apoc.when` but this doesn't seem to work either. It seems that Cypher is insisting on having a **relationship** pattern but I just want to test for existence of a **node with a certain property's value**.

```auto
RETURN
apoc.do.when(exists {(u:User {name: "abc@xyz.at"})}, "RETURN true", "RETURN false") 

```

> Invalid input '}': expected whitespace or a relationship pattern (line 2, column 67 (offset: 73))  
> "apoc.do.when(exists {MATCH(n) WHERE (u:User {name: "abc@xyz.at"})}, "RETURN true", "RETURN false")"

We did come up with a few alternatives to using `EXISTS` of a property here:

> [@Check if node exists and use the result as a condition](https://community.neo4j.com/t/check-if-node-exists-and-use-the-result-as-a-condition/32069):
>
> Sorry, to ask this question for the 100th time, but none of the previous posts was similar to my problem: I just want to get back TRUE or FALSE if a node with a certain label and a certain value of a property exists. (u:User {user\_id: 1} =\> TRUE / FALSE All other posts where about MERGE and so on, but I don't want to create anything, I want to use it as a condition in an apoc.do.when-function.

The documentation for `exists()` function doesn't have a pointer to **exists subqueries** :

> **[Predicate functions - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/functions/predicate/#functions-exists)**
>
> Predicates are boolean functions that return \`true\` or \`false\` for a given set of non-\`null\` input.

Sorry for my confusion... I do think if there was an easy way to test for property-with-a-value existence, it would be helpful.

---

_[View the full topic](https://community.neo4j.com/t/check-if-node-exists-proposal-for-a-new-apoc-function/32094)._
