I have a function that returns a table. It takes one parameter and returns one row.
I want to select the values from that function along with columns from another table in the same SELECT staement.
Something like this:
SELECT a.col1, a.col2, b.col1, b.col2
FROM tab1 a INNER JOIN
func1(a.col1) b ON a.col1 = b.col1
WHERE a.col1 IN (123,456,789)
This doesn't work, but is there a way I can do this.
So, for example, if func 1 returns the following for each of the three values in the example:
col1 col2
123 abc
456 def
789 xyz
then I am expecting something like the following results from my query:
col1 col2 col1 col2
123 xxx 123 abc
456 yyy 456 def
789 zzz 789 xyz
I can do it like this, but I'd rather not call the function multiple times for each column I want from the function:
SELECT col1, col2, (SELECT col1 FROM func1(a.col1)), (SELECT col2 FROM func1(a.col1))
FROM tab1 a
WHERE a.col1 IN (123,456,789)