In definition;

from T1, T2

Cross Join: If T1 has N rows, T2 has M rows, the result set will have N x M rows.

If T2 has no row, then result of the JOIN has no row also.

However, I want N rows (from T1), what can I do?

Any suggestion?

Note: I want cartesian product, there is no shared column between the tables.

  • sounds as if you want a full outer join instead – a_horse_with_no_name Aug 21 '18 at 10:11
  • No I want cartesian product. There is no shared column between two table. – John Puskin Aug 21 '18 at 10:13
  • I know :) I asked how I solve my problem. – John Puskin Aug 21 '18 at 10:15
  • So you want the non-empty table if either one of the tables is empty, but a cross join if both have rows? – a_horse_with_no_name Aug 21 '18 at 10:15
  • Maybe but not a good solution. – John Puskin Aug 21 '18 at 10:18

You can't use CROSS JOIN if any of both sets has no rows for the output you want. You can simulate this behaviour with a FULL JOIN with an always true condition.

    FULL JOIN T2 ON true
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.