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)
 Filtered Query

Author  Topic 

tpayne
Starting Member

18 Posts

Posted - 2008-08-26 : 10:49:29
I have two tables. Client and Function. I need a query to show the client Name and function name if the function name <> "Marketing" or "Research". So, if it has either of those functions i don't want to see the client.

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-26 : 10:57:21
[code]
select *
from Client c inner join Function f on c.ID = f.ID
where f.function_name not in ('Marketing', 'Research')
[/code]


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

Go to Top of Page

tpayne
Starting Member

18 Posts

Posted - 2008-08-26 : 11:10:20
Great, thanks. However, I don't want to see the Client at all if they have those functions. (ClientA might have other functions but i don't want to see them at all if they have Marketing or Research.)

thanks again
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-08-26 : 11:33:00
Might not be the best / most efficiant way...


select *
from
Client c
inner join [Function] f on c.ID = f.ID
where
c.[<primary key>] NOT IN (
SELECT
c.[<primary key>]
FROM
Client c
inner join [Function] f on c.ID = f.ID
where
f.function_name in ('Marketing', 'Research')
)


-------------
Charlie
Go to Top of Page
   

- Advertisement -