WHERE tasks.project=projects.projectsID
AND projects.client = clients.clientID
assuming clientID is the PK in the clients table
also add clients to your FROM clause and clients.clientname to your SELECT list
A little side note:
There is no need to use "task.taskname" when outputting the results of a query...just use "taskname".
also...it's good practice when using foreign keys to tname the fields the same in the parent and child table. You have tasks.project and projects.projectsID....that should be...tasks.projectID and projects.projectID....makes life easier...a projectID is a projectID is a projectID ;-)
there's my 2 cents CDN for ya
Cheers
Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
phone: 250.480.0642
fax: 250.480.1264
cell: 250.920.8830
e-mail: [EMAIL PROTECTED]
web: www.electricedgesystems.com
----- Original Message -----
From: Chris Kavanagh
To: CF-Talk
Sent: Thursday, August 19, 2004 1:02 PM
Subject: A bit confused with links between tables
Dear list,
As the witching hour approaches and my first deadline draws near,
expect my stress levels to climb and my emails to get less and less
graceful. For now, I feel remarkably composed, although I don't
suppose I'll be getting to bed anytime soon.
Now: this query fetches some data from two tables.
<CFQUERY name="get_tasks" datasource=taskomatic>
SELECT
tasks.taskID,
tasks.taskname,
tasks.status,
tasks.project,
projects.projectsID,
projects.projectname,
projects.client
FROM tasks, projects
WHERE tasks.project=projects.projectsID
</CFQUERY>
Further down I have a table that looks something like this:
<CFOUTPUT query="get_tasks">
#task.taskname# #task.status# #projects.projectname#
#projects.client#
</CFOUTPUT>
The trouble is that the field project.client just returns the primary
key from another table (clients). I'd like it to display the field
clients.clientname.
I appreciate that this an extremely low hurdle to fall at but I've been
frying my brain with this stuff for days and I'm finding it hard to
think straight...
Kind regards,
CK.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

