Do something like this:

SELECT
        tremont.ID,
        tremont.field2,
        tremont.field3,
        charles.ID,
        charles.field2,
        charles.field3
FROM
        tremont, charles
WHERE
        0 = 0
        <cfif isdefined("form.title") IS "yes">
                <cfif form.title IS NOT "">
                AND title LIKE '#form.title#'
                </cfif>
        </cfif>

-----Original Message-----
From: Paul Campano [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 2:35 PM
To: SQL
Subject: Two table query issue


I have two tables, tremont and charles    I want to query info from both
tables, but filter the results based on form variables.  Something like this
works
fine:

SELECT ID, category, title, format, store
FROM charles
WHERE 0=0
<!--- conditions passed from search --->
<cfif isdefined("form.title") IS "yes">
     <cfif form.title IS NOT "">
  AND title LIKE '#form.title#'
  </cfif>
</cfif>

but if I try this and add tremont, the second table, into the FROM clause I
get this error:

The specified field 'ID' could refer to more than one table listed in the
FROM clause of your SQL statement.

How can I get results from both tables and still be able to filter them
through the form variables?  Thanks


Paul



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                        

Reply via email to