SELECT ... FROM forms f LEFT JOIN staff_assignments a ON f.form_id = a.form_id LEFT JOIN staff s ON a.staff_id = s.staff_id;
Given that left joins are faster in MySQL anyway, this also gives you speed. Cheers /rudy -----Original Message----- From: MightyData [mailto:[EMAIL PROTECTED] Sent: donderdag 10 juli 2003 6:05 To: MySQL Subject: JOIN within LEFT JOIN I am using MySQL 3.23.54. I have the following table structure. FORMS form_id (PK) form_name STAFF ASSIGNMENTS staff_assignment_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_ASSIGNMENTS. 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_name, staff.last_name FROM forms LEFT JOIN staff_assignments ON forms.form_id = staff_assignments.form_id (JOIN staff on staff_assignements.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/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]