Answer the question
In order to leave comments, you need to log in
How to add JSON_TABLE to the end of the FROM section in AR in a query?
Hello!
There is an artist table in the database with a data_json field that stores json, I want to use AR to add the following code to the end of the FROM section:
JSON_TABLE(data_json, '$.songs[*]' COLUMNS (
name VARCHAR(128) PATH '$.name',
duration INT PATH '$.duration'
)
) songs
$query->from([
'artist',
'JSON_TABLE(data_json, '$.songs[*]' COLUMNS (
name VARCHAR(128) PATH '$.name',
duration INT PATH '$.duration'
)
) songs'
])
Answer the question
In order to leave comments, you need to log in
I don't know how your case works, but try this query to make subqueries.
$subQuery = Model::find()->from(...); // JSON_TABLE
$query = Model::find()->from($subQuery)->join(...);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question