Thanks for everyones input on my problem, it really helped.
Juliano's solution was exactly what i was looking for!!
Thanks again
Guy
> You are right I overlooked that part, my bad sorry
>
>
>
>
> -----Original Message-----
> From: Zadoyen, Eva [mailto:EZadoyen@s...]
> Sent: Monday, January 07, 2002 12:30 PM
> To: sql language
> Subject: [sql_language] RE: Exactly what am i doing wrong here???????
>
>
> Denis,
> Your solution will return all Clients who has at least one
> TargetGroupcode out of all( that's what "in" stands for). The neat
> solution will be to include 'HAVING' clause as was suggested by Juliano
> Moraes Rodrigues. But my solution with joins works too, and the choice
> depends on a table
> size: the Having clause executes after selection and IT will return all
> records that fit a WHERE clause and only after that will test HAVING
> clause. JOINS return only required records so...
> Eva
>
> -----Original Message-----
> From: Denis [mailto:dgobo@w...]
> Sent: Monday, January 07, 2002 11:51 AM
> To: sql language
> Subject: [sql_language] RE: Exactly what am i doing wrong here???????
>
>
> That's exactly the same as
> select ClientID
> from MyTable where TargetGroupCode in (5600,5519,5520)
> No need for 3 joins here
>
> I think what he wants to accomplish is to get all the data back without
> having to put in the 3 values, ie he wants all clientid's back in 1
> resultset This would work but I don't think this is all he wants either
> SELECT clientID
> FROM SQLTry
> GROUP BY clientID
>
>
>
> -----Original Message-----
> From: Zadoyen, Eva [mailto:EZadoyen@s...]
> Sent: Monday, January 07, 2002 11:42 AM
> To: sql language
> Subject: [sql_language] RE: Exactly what am i doing wrong here???????
>
>
> Guy,
> How about using joins:
>
> select ClientID
> from MyTable t1
> inner join MyTable t2 on t1.ClientID = t2.ClientID
> inner join MyTable t3 on t1.ClientID = t3.ClientID
> where t1.TargetGroupCode = 5600 and t2.TargetGroupCode = 5519 and
> t3.TargetGroupCode = 5520
>
> Try it.
>
> Good luck.
> Eva
> -----Original Message-----
> From: Guy Harwood [mailto:guy@h...]
> Sent: Monday, January 07, 2002 11:01 AM
> To: sql language
> Subject: [sql_language] RE: Exactly what am i doing wrong here???????
>
>
> that only seems to match against any one of the criteria. I need it to
> match all of them.. any ideas??
>
> > Select * from table where targetgroupcode in (5600,5519,5520) This
> > should do it If the targetgroupcode is a varchar field the this
> > should do it Select * from table where targetgroupcode in
> > ('5600','5519','5520')
> >
> > -----Original Message-----
> > From: Guy Harwood [mailto:guy@h...]
> > Sent: Monday, January 07, 2002 3:04 PM
> > To: sql language
> > Subject: [sql_language] Exactly what am i doing wrong here???????
> >
> >
> > I have a table which contains the 'target groups' that clients fall
> > into. A client can fall into many target groups.
> >
> > example table data:
> >
> > ClientID TargetGroupCode
> > -------------------------------
> > 5634 5600
> > 5634 5519
> > 5200 5600
> > 5634 5520
> > 5211 4999
> > 5211 5520
> >
> > I need to add some criteria to the end of a where statement which will
>
> > only return a client which falls into all the targetgroups that are in
>
> > the criteria.
> >
> > for example, show me all clients that fall into targetgroups 5600,5519
>
> > and 5520.
> >
> > this would only bring back client 5634 from the above table.
> >
> > Using IN, ALL and many subquery variations i cannot seem to do this.
> >
> > Can anyone help????
> >
> > Thanks in advance
> >
> > Guy
> > ---
> > Change your mail options at http://p2p.wrox.com/manager.asp or to
> > unsubscribe send a blank email to
> > $subst('Email.Unsub').
> >
>
> $subst('Email.Unsub').
>
> $subst('Email.Unsub').
>
>
> $subst('Email.Unsub').
>
> $subst('Email.Unsub').
>