Thanks, Aaron! That did it! (Maybe it's the medication I'm on...) :oP
Rick -----Original Message----- From: Aaron Rouse [mailto:[EMAIL PROTECTED] Sent: Monday, July 31, 2006 12:21 PM To: CF-Talk Subject: Re: Why would this query do this? Remove INSURANCE_COMPANIES from the FROM clause, you do not reference it anywhere else. On 7/31/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > Why would this query return a client for every insurance company? > > First, I'm running a query to get all the insurance companies. > > Next, I'm running this query inside a loop of the insurance companies: > > <CFQUERY Name="Get_Clients" Datasource="#DSN#"> > > Select C.Client_ID, > C.Client_First_Name, > C.Client_Middle_Name, > C.Client_Last_Name, > C.Client_Name_Suffix > > from clients C, insurance_companies IC, accounts A > > where C.Client_ID = A.Client_ID > and A.Company_ID = '#Get_Insurance_Companies.Company_ID#' > > order by C.Client_Last_Name > > </CFQUERY> > > But instead of returning just the single client who has a > C.Client_IDwhich equals an A.Client_ID and where the A.Company_ID > equals the looped variable Get_Insurance_Companies.Company_ID, the > query is returning the client information once for every insurance > company in the insurance company table. > > Do I need a join for this? > > Thanks, > > Rick > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:248260 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

