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 2005 Forums
 Transact-SQL (2005)
 Joins

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-25 : 05:50:01
Hi,

Im trying to retrieve all the records back from one table joining onto another, im using a where clause where table a is joining table b (with the clause) but id like all the records returned anyways.....

table_a (id, product)
table_b (product, downloadtype)

select a.product, downloadtype
from table_a as a left outer join table_b as b on
a.product = b.product
where b.downloadtype = 'demo'

Thanks

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-09-25 : 06:06:58
Hi, Try this once

select a.product, downloadtype from table_a as a
left outer join table_b as b on a.product = b.product
and b.downloadtype = 'demo'
Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-25 : 06:09:07
Hi,

thanks for prompt reply, its almost but it gives me duplicates now, so

product, platform, download
1, 1, null
1, 2, null <---- not needed
1, 2, demo

does that make sense?

quote:
Originally posted by Nageswar9

Hi, Try this once

select a.product, downloadtype from table_a as a
left outer join table_b as b on a.product = b.product
and b.downloadtype = 'demo'

Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-09-25 : 06:15:20
quote:
Originally posted by cipriani1984

Hi,

thanks for prompt reply, its almost but it gives me duplicates now, so

product, platform, download
1, 1, null
1, 2, null <---- not needed
1, 2, demo

does that make sense?

quote:
Originally posted by Nageswar9

Hi, Try this once

select a.product, downloadtype from table_a as a
left outer join table_b as b on a.product = b.product
and b.downloadtype = 'demo'





Hi,

Can u post ur data in tables
Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-09-25 : 06:34:38
Table_a
id, product
1, Mars
2, Battle

Table_b
product, DownloadType
Mars, Demo
Battle, Full

Im hoping to get it to show
1, Mars, Demo
1, Mars, Null

quote:
Originally posted by Nageswar9

quote:
Originally posted by cipriani1984

Hi,

thanks for prompt reply, its almost but it gives me duplicates now, so

product, platform, download
1, 1, null
1, 2, null <---- not needed
1, 2, demo

does that make sense?

quote:
Originally posted by Nageswar9

Hi, Try this once

select a.product, downloadtype from table_a as a
left outer join table_b as b on a.product = b.product
and b.downloadtype = 'demo'





Hi,

Can u post ur data in tables

Go to Top of Page
   

- Advertisement -