Skip to content
Advertisement

What is the functioning of “->” operator in MYSQL joins?

I’m using Sequelize, and trying to learn from the queries it constructs. I have some complicated one-to-many relationship between few models, so i come across this query:

The query itself is not important, but i would like to understand the meaning of the “->” operator, like in:

ScrumLists->ScrumCards.content AS ScrumLists.ScrumCards.content

Advertisement

Answer

In this context, the -> has no special meaning. It just belongs to a table alias that is defined in the query, here:

Once the alias is defined, it is used to refer to the corresponding table in the query, like:

Note that this is really a bad choice to use such table alias. -> is meaningful in MySQL (it’s a JSON operator that is a synonym for JSON_EXTRACT()). So using it in a table alias requires quoting the identifier everytime you use it. I would strongly suggest changing the table alias to something that is less tricky, and does not require quoting (ScrumLists_ScrumCards would be good enough).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement