CROSS JOIN with one empty table sql server -


i have 2 tables myfull , myempty. need combination of records both tables. sometimes, myempty table might have no records, in scenario need return records myfull. have tried:

 --q1 >> returns no results  select *  myfull cross join myempty   --q2 >> returns no results  select * myfull, myempty 

i though of using left join have no common key join on. sqlfiddle

try this:

select * myfull left join myempty on 1=1 

though aware if have multiple records in myempty, repeat records myfull once every record in myempty. effectively, number of records in results myfull * myempty (unless myempty has no records).


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -