Robert Dickey Robert Dickey - 2 years ago 73
PHP Question

MySQL Join Query with Multiple Joins

I have three different tables I am trying to pull info from. Related in different ways. I am trying to find a Join statement that will allow me to pull the information a little better than using the two queries I am now.

Here is what I have

SELECT * FROM reports LEFT JOIN students USING (sID)

This allows me to properly merge the two tables. However - There is a row in the reports table named pID. I have another table named test, that also has a matching pID row, along with other data. I am trying to access the data from that table as well. Is it possible to join three tables in that way? Not only getting data from the sID, but the pID as well

Answer Source

You can do the following

FROM reports
LEFT JOIN students USING (sID)

Where table3 is the name of your table.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download