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
 Retrieval Query - Company data Vs User

Author  Topic 

velnias2010
Posting Yak Master

125 Posts

Posted - 2010-01-28 : 05:12:57
Hey what im trying to do is to retrieve all Companies from tblCompany which dont yet have a certain user set up.

So I have tblCompany and tblUser

tblUser has a column called userType.

I want to make sure all companies have a user type of "2" if they dont I want the list of which dont I dont care about the ones that do.

So again I wish to retrieve all companies joined with tblusers which have no record of any user with user type 2.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-28 : 05:15:01

select c.* from companies as c where not exists
(select * from UserType where companyid=c.companyid and usertype=2)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -