Skip to content
Advertisement

SQL Join ON clause valid referencing on aliases

I am generating an SQL query and I need to get the data from a JSON stored on a field of my table. It goes something like this

So basically I am trying to get put a connection with tables creation and lookup_detail through field FACILITY_DATA which has JSON data and alias of loanType to reference against DETAIL_CODE field. However, I get this error

Is there anything I could do to work on this? I tried to search what are the valid reference to ON clause of JOIN operation, but I only get the typical ways.

Advertisement

Answer

Either repeat the expression in the ON clause, or join with a subquery.

Also, you probably should be using JSON_UNQUOTE() rather than REPLACE(). Or you can use the ->> operator, which extracts and unquotes in one step.

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