SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 union
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

415 Posts

Posted - 04/11/2013 :  11:03:00  Show Profile  Reply with Quote
i have tableA where already did the total count with the country:

tableA:
ID TotalSold Blue Red Code
1 10 5 5 ABC
2 3 2 1
3 40 30 10
4 15 5 10 DEF

i have another tableB which store the total amount of COde:

tableB:
Code Total
ABC USD89
DEF USD90

But when i try to inner join the code the total Sold will only appear with the code as below:

ID TotalSold Blue Red Code Total
1 10 5 5 ABC USD89
4 15 5 10 DEF USD90

How can i appear all as below:?

ID TotalSold Blue Red Code Total
1 10 5 5 ABC USD89
2 3 2 1
3 40 30 10
4 15 5 10 DEF USD90

James K
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 04/11/2013 :  11:20:14  Show Profile  Reply with Quote
Do a LEFT JOIN instead of INNER JOIN with the tableA on the left side (first table) and tableB on the right side (second table)
select a.*,b.Total
from TableA a left join TableB b on
	a.Code=b.Code
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000