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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 join and result include no match from both side

Author  Topic 

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2010-06-27 : 23:34:13
I have this data...


table1
select 1 as id, 1 qty union all
select 2 as id, 1 qty union all
select 4 as id, 4 qty union all

table2
select 1 as id, 1 sqty union all
select 2 as id, 3 sqty union all
select 3 as id, 5 sqty

I want to join the two table. However, I want to include the no match data from both side of the table.

Result...
select 1 as id, 1 qty , 1 sqty union all
select 2 as id, 1 qty , 3 sqty union all
select 4 as id, 4 qty , null sqty union all
select 3 as id, null qty, 5 sqty


Thanks




.


For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-27 : 23:41:51
use FULL OUTER JOIN


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2010-06-28 : 02:52:43
thanks KH

For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page
   

- Advertisement -