I am using MySQL 3.23.54. I have the following table structure.
FORMS
form_id (PK)
form_name
STAFF ASSIGNMENTS
staff_assignmen t_id (PK)
form_id (FK)
staff_id (FK)
STAFF
staff_id (PK)
first_name
last_name
For each record in FORMS there may be zero, one or multiple records in STAFF
ASSIGNMENTS. I need to perform a left join from FORMS on STAFF_ASSIGNMEN TS.
When there is a record in STAFF ASSIGNMENTS, I need to perform a join with
STAFF to retreive staff name. Here is my attempt at the query.
SELECT forms.form_id, forms.form_name , staff.first_nam e, staff.last_name
FROM forms LEFT JOIN staff_assignmen ts ON forms.form_id =
staff_assignmen ts.form_id (JOIN staff on staff_assigneme nts.staff_id =
staff.staff_id)
How do I need to write the query?
-------------------------------------------------------------------------
Kirk Bowman Direct: 972-492-7523
MightyData, LLC http://www.mightydata.com
-------------------------------------------------------------------------
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ie.nctu.edu.tw
FORMS
form_id (PK)
form_name
STAFF ASSIGNMENTS
staff_assignmen t_id (PK)
form_id (FK)
staff_id (FK)
STAFF
staff_id (PK)
first_name
last_name
For each record in FORMS there may be zero, one or multiple records in STAFF
ASSIGNMENTS. I need to perform a left join from FORMS on STAFF_ASSIGNMEN TS.
When there is a record in STAFF ASSIGNMENTS, I need to perform a join with
STAFF to retreive staff name. Here is my attempt at the query.
SELECT forms.form_id, forms.form_name , staff.first_nam e, staff.last_name
FROM forms LEFT JOIN staff_assignmen ts ON forms.form_id =
staff_assignmen ts.form_id (JOIN staff on staff_assigneme nts.staff_id =
staff.staff_id)
How do I need to write the query?
-------------------------------------------------------------------------
Kirk Bowman Direct: 972-492-7523
MightyData, LLC http://www.mightydata.com
-------------------------------------------------------------------------
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ie.nctu.edu.tw