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
 General SQL Server Forums
 New to SQL Server Programming
 Join Query

Author  Topic 

michaelp2010
Starting Member

2 Posts

Posted - 2010-08-06 : 06:36:53
Hi folks

I need some advice on a join statement. Here's my scenario.

I have two tables, one with property details and one with repair details.

The two have a common field of property reference, what I need to do is return all properties which don't have any entries in the repair table.

Any guidance would be much appreciated.

Thanks
Michael



khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-06 : 06:42:52
[code]select *
from property p
where not exists
(
select *
from repair r
where r.reference = p.reference
)[/code]


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

Go to Top of Page

michaelp2010
Starting Member

2 Posts

Posted - 2010-08-06 : 06:58:57
Hi khtan, thanks for the prompt solution..

quote:
Originally posted by khtan

select *
from property p
where not exists
(
select *
from repair r
where r.reference = p.reference
)



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



Go to Top of Page
   

- Advertisement -