0

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.

3
  • 3
    Please provide actual details Commented May 2, 2018 at 12:26
  • You're selecting 1. Perhaps, you want to select all columns (select *). Commented May 2, 2018 at 12:29
  • I was selecting columns in an incorrect manner. Selecting all required columns in 1st select statement solved the problem Commented May 2, 2018 at 12:38

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, yes all required columns should be a part of first select statement
@ProgrammingEnthusiast since your problem has been solved, please, mark the best answer as the correct answer, so later visitors will see the solution at first glance.
1

You are not retrieving data from t1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.