Amaan Khan
Amaan Khan

Reputation: 89

Can we join 2 table valued functions

I am trying to join 2 table-valued functions using a common column returned by each function respectively.

I am trying to do something like this :

Select * from function1(),function2() where id=1;

When I do this I get the error saying the column is ambigiuos as it is present in both the set of columns retuned.

How can I join these 2 table-valued functions?

Upvotes: 0

Views: 49

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269873

You can. But as with anything else in the from clause, table valued functions need to given aliases. And: Never use commas in the FROM clause.

So:

select *
from function1() f1 join
     function2() f2
     on f1.id = f2.id;

Upvotes: 2

Related Questions