> Pseudo code, cozz I know it wont work.
> 
> I basically need to do the equiv of an AND on rows, so a 
> version of this pseudo code that actually works.
> 
> Select distinct memberID
> Where QID = 1 and answer = "this"
> And QID = 2 and answer = "that"
> 
> This wont work beacuase it will try and get a row where the 
> columns are equal to both.

Messy, but how about taking the OR query :

<cfquery name="qorig">
    ...
    (QID = 11 and answer = "whatever"
    OR
    QID = 12 and answer = "something")
    AND
    Addiitonal requirements here
</cfquery>

...and then dynamically build a new query object using QofQ to grab
those with two entries [untested!] :

<cfset qnew = querynew("MID")>
<cfloop query="qorig">
    <cfquery name="qtemp" dbtype="query">
        SELECT * FROM qorig WHERE MID = #qorig.MID#
    </cfquery>

    <!--- test if 2 rows returned --->
    <cfif qtemp.recordcount EQ 2>
        <cfset queryaddrow(qnew)>
        <cfset querysetcell(qnew, "MID", qtemp.MID, qtemp.recordcount)>
    </cfif>
</cfloop>

That'll give you a query containing all the MIDs of those with both
answers.  It will have two entries for each person though, but you can't
have everything...  :o\

Like I said, it's messy - Monday-code...  Eugh, Monday evening.  Bring
on the end of the week.  :oD

Tim.

-------------------------------------------------------
Tim Blair
Web Application Engineer, Rawnet Limited
Direct Phone : +44 (0) 1344 393 441
Switchboard : +44 (0) 1344 393 040
-------------------------------------------------------
rawnet ltd
Atrium Court
Bracknell                    [EMAIL PROTECTED]
Berkshire                    Tel : +44 (0) 1344 393 040
RG12 1BW, UK                 http://www.rawnet.com
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------




-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to