我有三张桌子:
+------------------------------------------+
| profile_employee |
+------------------------------------------+
| id | first_name | last_name | phone | cv |
+----+------------+-----------+-------+----+
+------------+
| joburi |
+------------+
| id | titlu |
+----+-------+
+---------------------------------------+
| job_to_profile |
+---------------------------------------+
| id | id_job | id_profile | created_at |
+----+--------+------------+------------+
我想从这三个表中选择所有信息,我有这个查询,但只选择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
如果我在这里经历了一大堆的答案,仍然在为得到我需要的结果而揪头发。任何SQL专家都能看到一个简单的解决方案吗。所需的潜在连接正在煎熬我的大脑。
最佳答案
使用INNER JOIN
可以使用以下命令:
SELECT *
FROM profile_employee pe INNER JOIN job_to_profile jtp ON pe.id = jtp.id_profile
INNER JOIN joburi j ON jtp.id_job = j.id