Will

Sounds like all you need is to join the two tables.

SELECT m.blah, d.blah
FROM   members m, details d,
WHERE  d.main_body LIKE '%#pref1#%'
AND    members.name_of_primary_key =
details.name_of_column_that_references_it

Nick

-----Original Message-----
From: W Luke [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 17, 2000 3:01 PM
To: CF-Talk
Subject: Queries inside other queries


Hi,

I feel a bit stupid asking this, but I just can't work it out.  Whenever I
want to do some complicated SQL, I usually end up needing to run lots of
queries, inside other cfoutputs and queries, but none of them ever work.

My latest scenario is this; as part of a scheduled task, I need to take each
member's email address and `preferences` from the members' table, and query
another table based on that.  Something like this:


<cfquery name="getmembers" datasource="six">
    SELECT * FROM members
</cfquery>

<cfoutput query="getmembers">
    <cfquery name="getdetails" datasource="six">
        SELECT * FROM details WHERE main_body like '%#pref1#%'
</cfoutput>

If any results are returned from `getdetails,` I want to mail them to that
person's email address defined in `getmembers.`  And do that for every
member in the Members table.  Incidentally, in each member profile there are
3 "prefs" (pref1,2,3)

It seems basic, but I just can't fathom what I need to do.

Thanks

Will

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists


**********************************************************************
Information in this email is confidential and may be privileged.
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to