Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2010-08-20 : 11:19:27
|
| Im going to have two tables on any given day table one could have more rows then table two but the next day it could switch but I need to make sure all the rows from both tables are always shown any suggestions? |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-08-20 : 11:21:41
|
| What do you mean "always shown"?? Can you elaborate. |
 |
|
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2010-08-20 : 11:28:26
|
| The all the data from both tables is always shown. Im thinking if I did a left join on table 1 when it has more its fine, but the next day if there more in table 2 id lose those columns from table 2. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-20 : 12:05:43
|
| then do a full outer join between tables and use COALESCE(t1.field,t2.field) to get field value.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-08-20 : 12:10:00
|
Another alternative:SELECT * FROM TableOneUNIONSELECT * FROM TableTwo |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-20 : 12:14:33
|
quote: Originally posted by Lamprey Another alternative:SELECT * FROM TableOneUNIONSELECT * FROM TableTwo
dependswhat if there are some different columns and we have to show all the columns from both table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|