简体   繁体   English

MYSQL内部联接但具有多个列

[英]MYSQL Inner Join but with multiple columns

SELECT * FROM people p INNER JOIN job j ON p.job_id = j.id ORDER BY j.id ASC

The above is how I am using Inner Join to add j.id to p.job_id but what if I want to add j.description to j.job_description ? 上面是我使用Inner Joinj.id添加到p.job_id但是如果我想将j.description添加到j.job_description怎么j.job_description

I have tried 我努力了

SELECT * FROM people p INNER JOIN job j ON p.job_id = j.id INNER JOIN job j ON p.job_desc = j.description ORDER BY j.id ASC

but this does not work. 但这不起作用。

The idea is to add contents from my table job to the table people 这个想法是将表格job中的内容添加到表格people

If I understand you right, this must be the solution: 如果我理解正确,那么这必须是解决方案:

SELECT * 
FROM people p INNER JOIN job j ON p.job_id = j.id and p.job_desc = j.description 
ORDER BY j.id ASC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM