logo       

Query clause from previous query: msg#00043

cms.cold-fusion.user.azcfug

Subject: Query clause from previous query

Hello -

I got a question for the group collective.

I have a query:

<CFQUERY DATASOURCE="#dsn#" NAME="qry1">
SELECT * FROM table1
WHERE field1='abc' OR field1='xyz'
</CFQUERY>

This query will pull all data if field1 is either abc or xyz, right? Right,
it works fine. This is where things get interesting... I've got another
table:

<CFQUERY DATASOURCE="#dsn#" NAME="qry2">
SELECT clause FROM table2
WHERE ID=1
</CFQUERY>

Let's say the entry for ID 1 in table2 looks like this:

ID clause
-- ----------------------------
1 field1='abc' OR field1='xyz'

If I create another query:

<CFQUERY DATASOURCE="#dsn#" NAME="qry1Alt">
SELECT * FROM table1
WHERE #qry2.clause#
</CFQUERY>

It throws an error (and this DB is Access for testing):

Syntax error (missing operator) in query expression 'table1.field1=''abc''
OR table1.field1=''xyz''

It is putting an extra set of single quotes around the operands...
Obviously, if I leave off the single quotes in the clause field of table2 I
get a data type mismatch. Is there a way to make this work? If this is
confusing, buy you still want to help, I am happy to provide actaul queries
with actual table and field names...

Thanks!
Gregg Bookspan
Director of Internet Technologies
Marks-Ferber Communications, LLC
Tel602-200-6811 Fax602-200-6802

PS - Looking for a full-time ColdFusion and/or ASP developer






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise