sql - results from both tables even corresponding rows does not exist in other table -


this question has answer here:

i results both tables corresponding rows not exist in each other table. join should use results below. tried full, no luck.

table 1:

ca  cb  cc === === === aa  11  x1 bb  22  x2 cc  33  x3 ee  44  x4 

table 2:

ca  cb  cd === === === aa  11  y1 bb  22  y2 ff  55  y5 gg  66  y6 

expecting results like:

ca  cb  cc      cd === === ===     === aa  11  x1      y1 bb  22  x2      y2 cc  33  x3      (null) ee  44  x4      (null) ff  55  (null)  y5 gg  66  (null)  y6 

select    coalesce (t1.ca, t2.ca) ca   ,coalesce (t1.cb, t2.cb) cb   ,cc   ,cd table1 t1 full join table2 t2 on t1.ca = t2.ca , t1.cb = t2.cb order     coalesce (t1.ca, t2.ca)    ,coalesce (t1.cb, t2.cb)  

sqlfiddle


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -