SELECT C.ID, T.ID
FROM Charles C, Tremont T
WHERE C.something = T.somethingelse

You give your tables an alias (usually a letter, keep it short) and refer 
to ALL your variables in your two tables using the appropriate alias. If 
you have fields in both tables named the same, you can rename one (or both):

SELECT C.ID AS CharlesID, T.ID AS TremontID

At 02:34 PM 1/16/2003 -0500, you wrote:
>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
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                        

Reply via email to