Jump to content

php mysql join 3 tables


jarecki74

Recommended Posts

Please help

I have a SQL query

 

SELECT c.id_customer, c.firstname, c.lastname, count (o.id_order) AS ordercnt FROM pslh_customer c LEFT JOIN pslh_orders o ON c.id_customer = o.id_customer GROUP BY o.id_customer

 

gets data from 2 tables pslh_customer and pslh_orders and returns first name, last name, numberorders 

I need to add a phone number from the third table, pslh_address,  phone field

for result

as id_customer firstname lastname ordercnt phone

1 John DOE 5 666666666

2 Me because 1 666666666

 

I can't connect 3 tables :(

 

in the final step , I need to create a php file that connects to the database, executing this query and displaying the result

 

 

Edited by jarecki74 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...