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_ID which
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:248248
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to