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
 blank
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Christech82
Starting Member

Hungary
20 Posts

Posted - 04/10/2013 :  14:42:47  Show Profile  Reply with Quote
blank

Edited by - Christech82 on 04/14/2013 10:13:00

James K
Flowing Fount of Yak Knowledge

3575 Posts

Posted - 04/10/2013 :  15:11:39  Show Profile  Reply with Quote
You could query like shown below:
select * from HOUSE h
where not exists
(
	select * from RENT_AGREEMENT r
	where r.HOUSE_NO = h.HOUSE_NUM
);
Go to Top of Page

Christech82
Starting Member

Hungary
20 Posts

Posted - 04/10/2013 :  15:23:49  Show Profile  Reply with Quote
quote:
Originally posted by James K

You could query like shown below:
select * from HOUSE h
where not exists
(
	select * from RENT_AGREEMENT r
	where r.HOUSE_NO = h.HOUSE_NUM
);





It is worked Thank you much for your help James
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/11/2013 :  02:22:26  Show Profile  Reply with Quote
you can also achieve it using LEFT JOIN or NOT IN

select * from HOUSE h
where h.HOUSE_NUM not in
(
	select r.HOUSE_NO from RENT_AGREEMENT r 
)

select h.* from HOUSE h
LEFT JOIN RENT_AGREEMENT r
ON r.HOUSE_NO = h.HOUSE_NUM
WHERE r.HOUSE_NO IS NULL


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 04/15/2013 :  00:17:51  Show Profile  Reply with Quote
Hi Christech82,

Don't delete your content after getting solution.. These posts will help others who have this type of problems
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.03 seconds. Powered By: Snitz Forums 2000