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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -