all groups > sql server new users > june 2005 >
You're in the

sql server new users

group:

simple query select



simple query select Aleks
6/23/2005 11:38:07 AM
sql server new users: I have an sql to select 'customers', something like

Select * from clients
inner join cases on clients.id = cases.clientid

The client may have multiple cases and if I run the query like that I may
get the same client multiple times, how can I only display the client once
when there are multiple results.

The have an ID which is unique so that might help .. help is appreciated.

Aleks

Re: simple query select Aleks
6/23/2005 8:35:12 PM
No,

I only need the clients, but I need to filter out by a column that is in the
cases column, but I don't want them repeated if there are multiple cases.

A

"Jens Süßmeyer" <Jens@Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:eyoeURDeFHA.612@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: simple query select Aleks
6/23/2005 9:55:30 PM
This is the actual sql

This is actually the sql.

SELECT c.Id , c.CaseId , c.EmpId, c.AlienId, c.FirmAddressId, d.UserId,
d.FirstNm , d.MiddleNm, d.LastNm , c.FirmId, c.MainCase ,
b.MaidenNm,e.Processcatalog,
c.archived, d.NiStatus, d.ExpiresOn FROM Cases c

INNER JOIN Users as d ON c.AlienID = d.userid inner join users as b ON
c.empid = b.userid
INNER JOIN Processcatalog as e ON c.Process = e.ProcesscatalogID
WHERE c.EmpID=MMColParam and d.FirstNm LIKE 'MMColParam3%' and d.LastNm LIKE
'MMColParam4%' AND c.archived =0 and d.Usertype = 'Contact'

What I need is to select only those where d.userid are different from one
another. How can I do this ?

Aleks




[quoted text, click to view]

Re: simple query select Jens Süßmeyer
6/23/2005 10:44:19 PM
Of you got two sources (cases and customers) you haveto qualify the results.
* will show all columns of the query and the two table, so placing the
Cases.
if you want only the cases solves the problem (or name the indivual columns
like Select Cases.caseID,Cases.SOmeothercolumn...)

--
HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---
"Aleks" <arkark2004@hotmail.com> schrieb im Newsbeitrag
news:eYl4h4CeFHA.2420@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: simple query select Jens Süßmeyer
6/24/2005 12:00:00 AM
Select * from Customers AS CO
Where Exists
(
Select * from Cases CA where CA.CustomerID = CO.CUstomerID
)

THat should work.

HTH, Jens Suessmeyer.

"Aleks" <arkark2004@hotmail.com> schrieb im Newsbeitrag
news:u22mcVGeFHA.2700@tk2msftngp13.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button