View Full Version : SQL Inner Join on 3 tables

04-10-2006, 07:31 AM
Hi, newbie here!

I have an sql problem i was wondering someone might be able to help me with as i am new to this and struggling a bit.

Im building a dynamic website in php, MySQL and have a table called tbl_matchReports that i would like to update. This table has two foreign keys from two other tables tbl_users & tbl_team.

I have created an update from, via the dreamweaver wizard, to update the record based on it being passed the tbl_matchReports primary key via the URL.

My problem is that i need to join the three tables so that i can create 2 dynamic drop down menus in the update form that will show the actual value based on the foriegn key in the tbl_matchReports and be able to list all the other possible values from the other tables; i.e. tbl_users & tbl_team.

I know you can do this with two tables using an INNER JOIN but i cant work out how to do it with 3.

Any help would be much appreciated


04-10-2006, 08:02 AM

SELECT * FROM invoice LEFT JOIN authority on auth_id = inv_auth_id LEFT JOIN user on usr_id = inv_cost_manager WHERE .....

make sure its the correct join for the task

04-10-2006, 09:03 AM
Thanks for the quick responce and help.

I googled Left Join and now understand what is happening.

Works now cheers!