I have to join Table A (tax related) to Table B (customer related)
I pull at most 1 record but sometimes no record.
Now I need to return the combined record to the user
I though doing a simple Cartesian product would have work
SELECT * FROM TableA, TableB
but that does not work if TableA or TableB is empty
I would do a full outer join but right now do not have anything to join on. I could create temp tables with identity columns and then join on them (since 1 = 1)
But I was looking for a different way?
Thank you
Per your own suggestion, you could use a full outer join
to guarantee a row:
select *
TableA a
full outer join
TableB b
on 1=1
To always return at least one row, even if TableA
and TableB
are emtpy, you could use a fake table:
select *
from (
select 1 as col1
) fake
left join
TableA a
on 1=1
left join
TableB b
on 1=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With