There is a table with 4 rows. Write a single SELECT statement which would return 16 rows. Use of temp table, CTE, Union all, and JOIN is not allowed
Write a single SELECT statement which would return 16 rows.
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Sachin SinghRank #66 · 26.2K reputationPosted Mar 2, 2023, 12:28 PM EST
select * from tableName t1, tableName t2
. Idk might be cross join he was talking about as we don't need to use join keyword for cross join.
but this question doesn't make sense.
Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 2, 2023, 7:54 AM EST
Hi,
I am not sure about your question, however, if you have 4 rows in a table, why/how can you need to return 16 rows?
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 2, 2023, 8:29 AM EST
@Rijwan Ansari someone ask a quetion to me. I was also surprised to listen this question also.
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 2, 2023, 1:45 PM EST
One way to achieve this is by using CROSS JOIN with the table itself:
SELECT t1.*, t2.* FROM table_name t1 CROSS JOIN table_name t2;This will return a total of 16 rows (4 x 4), with each row joined with every other row in the table.