ProgrammingEnthusiast
ProgrammingEnthusiast

Reputation: 43

Cross join returning row from only one table

I'm trying to get two different columns by cross joining on same table but getting only on e column. Following is the sample query :

select 1 from dual cross join (select 2 from dual) t1;

Expected Result : 1 2

but getting only 1.

Upvotes: 0

Views: 1182

Answers (2)

Lajos Arpad
Lajos Arpad

Reputation: 76787

You have the select clause of

select 1

where you select a single column. If you want an output of 1 2 then use

select 1, 2

as your select clause.

Upvotes: 2

Yogesh Sharma
Yogesh Sharma

Reputation: 50173

You are not retrieving data from t1

select 1 as id, t1.*
from dual cross join (select 2 id1 from dual) t1;

Upvotes: 1

Related Questions