I am trying to do a ColdFusion Query of Query. The first query qEL
returns several records. One of the rows is:
ELINKACCOUNTNUMBER WINACCNT WSTREAMBUSINESSUNIT WSTREAMOBJ WSTREAMSUB
101-40001-0000-15-001-00000-0000 216000012.32103.1750 216000012 32103 1750
Note in above: WSBusinessUnit value is 216000012, WSTREAMOBJ is 32103 and WSTREAMSUB is 1759
The second query is qEL2
which does return a bunch of records but only one row matches the record above with columns names of First
, Second
, and Third
respectively.
So I need to do a join or something to and here is my code:
<cfquery name="qFinal" dbtype="query">
SELECT
qEL.ELINKACCOUNTNUMBER AS ELAccountNum, qEL.WINACCNT AS WSAccountNum, qEL2.Description AS DESCRIPTION, qEL2.Posting_Edit_Code AS Posting_Edit_Code
FROM
qEL, qEL2
WHERE
qEL.WSTREAMBUSINESSUNIT = <cfqueryparam value="#qEL2.First#" CFSQLType="cf_sql_varchar" />
AND
qEL.WSTREAMOBJ = <cfqueryparam value="#qEL2.Second#" CFSQLType="cf_sql_varchar" />
AND
qEL.WSTREAMSUB = <cfqueryparam value="#qEL2.Third#" CFSQLType="cf_sql_varchar" />
</cfquery>
But this query doesn't return anything. Should I do a join instead somehow?
Thanks!
Edit 1: Maybe some syntax like this instead? Having trouble with a SQL Join in ColdFusion