Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PaulCatalin97's avatar

SELECT from three tables

I have three tables:

profile_employee -id -first_name -last_name -phone -cv

joburi -id -titlu

job_to_profile -id -id_job id_profile created_at

i want to select all of the information from all those three tables, i have this query but selects only first,last,phone,cv:

SELECT jtp.id, jtp.created_at as data_aplicare, profile_employee.first_name, profile_employee.last_name, profile_employee.phone, profile_employee.cv FROM profile_employee LEFT JOIN job_to_profile jtp ON jtp.id_profile = profile_employee.id

If been through a load of answers here and still tearing my hair out to get the results I need. Can any SQL gurus out there see a simple solution. The potential JOINs required are frying my brain.

Any help would be much appreciated. For the sake of my scalp, among other things ;)

0 likes
2 replies
Snapey's avatar

think of the three tables

profile <----> pivot <----> joburi

you need one join for each <---->

1 like
DevForAll's avatar
Level 5

Like @snapey said, you have to make 2 JOIN :

SELECT * FROM `job_to_profile` LEFT JOIN `profile_employee` ON profile_employee.id = `job_to_profile`.id_profile LEFT JOIN `joburi` ON `job_to_profile`.`id_job` = joburi.`id`

Replace * with the fields you need

1 like

Please or to participate in this conversation.