I am using standard SQL and I have table Order:
and I am trying to join it with table MenuItem
on Order item_ids array and MenuItem __id__ integer column and get array of MenuItem prices, but I am getting an error:
Correlated subqueries that reference other tables are not supported unless they can be de-correlated, such as by transforming them into an efficient JOIN.
How to avoid this error?
Query:
WITH menu_items AS
(
SELECT
__id__,
price
FROM
`potykion.MenuItem`
)
SELECT
*,
ARRAY(
SELECT
price
FROM
UNNEST(item_ids) AS id
JOIN
menu_items
ON
id = menu_items.__id__
)
FROM
`potykion.Order`



item_details? I don't see it in the sample data for theOrderstable.item_detailsis the record in one of the table. Still, please provide schema of your tables with few rows example and expected result. - Generically speaking - please edit your question to show a Minimal, Complete, and Verifiable example of the code that you are having problems with, then we can try to help with the specific problem. You can also read How to Ask.