WendelLana commented on issue #951:
URL: https://github.com/apache/age/issues/951#issuecomment-1567203145

   In your particular case, you don't need to use a WHERE clause, it's simply 
replaced with a MATCH clause, like this:
   ```
   SELECT * from cypher('munmud', $$
   MATCH (u:User {id: 'user1'})-[:WATCHED]->(m:Movie)
   WITH DISTINCT m as watchedMovies
        MATCH (g:Genre)<-[]-(watchedMovies)
        WITH DISTINCT g as genre
                MATCH (genre)<-[:BELONGS_TO]-(am)
                WITH DISTINCT am as allMovie
                        MATCH (u:User {id: 'user1'})-[:WATCHED]->(allMovie)
                        RETURN allMovie
   $$) as (V agtype);
   ```
   
   However, I didn't get why you need all this MATCH clauses if your query 
would return the same result with a simple query like this:
   ```
   SELECT * from cypher('munmud', $$
   MATCH (u:User {id: 'user1'})-[:WATCHED]->(m:Movie)
   RETURN m
   $$) as (V agtype);
   ```
   If you want to get all movies genres watched by a particular person than 
return all movies that another person watched from those same genres using a 
WHERE clause, you could do this:
   ```
   SELECT * from cypher('munmud', $$
   MATCH (u:User {id: 'user1'})-[:WATCHED]->(m:Movie)
   WITH DISTINCT m as watchedMovies
        MATCH (g:Genre)<-[]-(watchedMovies)
        WITH DISTINCT g as genre
                MATCH (genre)<-[:BELONGS_TO]-(am)
                WITH DISTINCT am as allMovies
                        MATCH (u:User)-[:WATCHED]->(allMovies)
                        WITH u as user, allMovies as movie
                                WHERE user.id = 'user2'
                                RETURN movie
   $$) as (V agtype);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to