Neo4j create a relationship with nodes with the same id problem

I have two different types of nodes that I load from a dataset. these nodes have the same id values ​​with different names. how can i relate between them using these same id values. I tried the following two separate codes, but there is no change. can you help?

match (movie:Movie {id:movie.movieId}), (movieGenres:MovieGenres {id:movieGenres.movieGenresId}) create (movie) - [:GENRE] -> (movieGenres)

match (movie:Movie where id(movie)=toInteger(movie.movieId))
match (movieGenres:MovieGenres where id(movieGenres)=toInteger(movieGenres.movieGenresId) ) merge (movie) - [:GENRE] -> (movieGenres)

Thank you very much it worked. I have one more problem. I have two separate node types movies_genres and directors_genres. but in one the name is visible on the nodes while the other is not. why could it be?

Screenshot 2022-08-03 142811.pngScreenshot 2022-08-03 142927.png
As seen in the picture, movieID and moviesGenresId have the same value. I wanted to associate nodes using them. I don't know if such a thing is possible. is it possible? thanks.

hi @Cobra cobra, thanks for your reply.
But when I try with the code you showed, there is no change.
I want to connect different nodes with same id's.
thanks again.

Hello @gusto :blush:

The id() function returns the Neo4j internal ID of node/relationship.

This query should do what you want:

MATCH (m:Movie) 
MATCH (g:MovieGenres) 
WHERE m.movieId = g.movieGenresId 
MERGE (m)-[:GENRE]->(g)

Regards,
Cobra

I guess you are looking for this.

This query should work normally

MATCH (m:Movie) 
MATCH (g:MovieGenres) 
WHERE toInteger(m.movieId) = toInteger(g.moviesGenresId) 
MERGE (m)-[:GENRE]->(g)

Neo4j Internal ID are unique so it won't be possible by definition. Do you have common ids between Movie and MovieGenres nodes?

Can you tell me all the properties you have for these two nodes and the type of this properties?

Can you share some queries to recreate your dataset?

Thank you so much.
(migrated from khoros post Solved: Re: Neo4j create a relationship with nodes with th... - Neo4j - 58668)

There was a typo in my query, the s was messing in moviesGenresId. You can try to also remove toInteger() functions.