Friday, 6 September 2013

mySQL Return field names from multiple foreign keys

mySQL Return field names from multiple foreign keys

I'm new to mySQL and was hoping to get some help. I have a table layed out
in the following way:
TASK
task_id *
tasktype_id (FK)
proj_id (FK)
empl_id (FK)
taskstat_id (FK)
hrs
notes
If I do a query like this, the results print out fine but the numeric
references to foreign keys are printed.
SELECT * AS task FROM task
INNER JOIN tasktype ON tasktype.tasktype_id = task.tasktype_id
WHERE taskstat_id = 1";
But I would like to print out the field names instead of field numbers for
the foreign keys in the resulting table. Any ideas? This is what I tried,
but without any luck.
SELECT task.task_id,
tasktype.tasktype_id,
project.proj_id,
employee.empl_id,
taskstatus.taskstat_id,
task.hrs,
task.note
FROM task, tasktype, project, employee, taskstatus
INNER JOIN tasktype ON tasktype.tasktype_id = task.tasktype_id
WHERE task.taskstat_id = 1";

No comments:

Post a Comment