What you need to do is alias the names in your query statement like so:

<CFQUERY name="get_tasks" datasource="taskomatic">
        SELECT
                tasks.task_id,
                tasks.name as taskName, 
                tasks.deadline,
                tasks.project_id,
                tasks.importance_id,
                tasks.owner_id,
                projects.project_id,
                projects.name as projectName, 
                people.person_id,
                people.name as personName, 
                importance.importance_id,
                importance.importance
        FROM tasks
                JOIN projects ON tasks.project_id = projects.project_id
                JOIN people ON tasks.owner_id = people.person_id
                JOIN importance ON tasks.importance_id =
importance.importance_id
</CFQUERY>

   <CFOUTPUT query="get_tasks">
     <td>#taskName#</td>
     <td>#projectname#</td>
     <td>#deadline#</td>
     <td>#importance#</td>
     <td>#personname#</td>
   </CFOUTPUT>

-----Original Message-----
From: Chris Kavanagh [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 17, 2005 1:02 PM
To: CF-Talk
Subject: basic: outputting data from several tables in one CFOUTPUT

Dear list,

I've got this query that gets data from three tables:

<CFQUERY name="get_tasks" datasource="taskomatic">
        SELECT
                tasks.task_id,
                tasks.name,
                tasks.deadline,
                tasks.project_id,
                tasks.importance_id,
                tasks.owner_id,
                projects.project_id,
                projects.name,
                people.person_id,
                people.name,
                importance.importance_id,
                importance.importance
        FROM tasks
                JOIN projects ON tasks.project_id = projects.project_id
                JOIN people ON tasks.owner_id = people.person_id
                JOIN importance ON tasks.importance_id =
importance.importance_id
</CFQUERY>

But the trouble is, the CFOUTPUT I thought would work doesn't:

   <CFOUTPUT query="get_tasks">
     <td>#tasks.name#</td>
     <td>#projects.name#</td>
     <td>#tasks.deadline#</td>
     <td>#importance.importance#</td>
     <td>#people.name#</td>
   </CFOUTPUT>

...because it doesn't seem to recognise the scopes ("Element TASKS.NAME 
is undefined in TASKS").  But I need the scopes because I (perhaps 
foolishly) have three fields called "name"!  Do I need to make all the 
field names in my database unique, or is there another way?

TIA!
CK.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190799
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to