これは、疑似コードが要求することを行います。
SELECT
Table2.parent,
MyFunction(Table1.value) AS function_value
FROM Table2
CROSS JOIN Table1
サンプル データを考えると、このクエリの結果は次のようになります。
PARENT FUNCTION_VALUE
------ ---------------------------
John value of function('Nice')
Mary value of function('Nice')
Mark value of function('Nice')
John value of function('School')
Mary value of function('School')
Mark value of function('School')
John value of function('Day')
Mary value of function('Day')
Mark value of function('Day')
これは、クエリが のすべての行と Table1 結合され Table2た のすべての行に対して関数を呼び出すためです。に 8 行、Table1に 10 行あるTable2場合、80 件の結果 (8 x 10) が得られます。各テーブルに 1,000 行ある場合、100 万件の結果 (1,000 x 1,000) が得られます。
Index各テーブルの列を使用して行を関連付ける場合は、代わりにこれを試してください。
SELECT
Table2.parent,
MyFunction(Table1.value) AS function_value
FROM Table2
JOIN Table1 ON Table2.index = Table1.index
サンプル データを使用すると、このクエリの出力は次のようになります。
PARENT FUNCTION_VALUE
------ ---------------------------
John value of function('Nice')
Mary value of function('School')
Mark value of function('Day')
これらのクエリのどちらも必要な結果をもたらさない場合は、サンプルの結果を提供してください。