嗨,我试图与夫妇 INNER JOIN 进行查询,我的错在哪里?
SELECT job_tbl.id, accounts.username AS starter, accounts.username AS worker, job_tbl.comment, job_tbl.date, job_tbl.status
FROM job_tbl
在 job_tbl.starter = accounts.id 上的 INNER JOIN 帐户
在 job_tbl.worker = accounts.id 上的 INNER JOIN 帐户
job_tbl 表在这里:
+----+---------+--------+---------+------+--------+
| id | starter | worker | comment | date | status |
+----+---------+--------+---------+------+--------+
| 1 | 1 | 3 | qwe | date | 10 |
+----+---------+--------+---------+------+--------+
| 2 | 2 | 1 | qwe | date | 10 |
+----+---------+--------+---------+------+--------+
此处的帐户表:
+----+------------+-----------+-------+
| id | username | extension | email |
+----+------------+-----------+-------+
| 1 | Julia | 100 | email |
+----+------------+-----------+-------+
| 2 | Eve | 101 | email |
+----+------------+-----------+-------+
| 3 | Max | 102 | email |
+----+------------+-----------+-------+
结果我希望它是:
+----+---------+--------+---------+------+--------+
| id | starter | worker | comment | date | status |
+----+---------+--------+---------+------+--------+
| 1 | Julia | Max | qwe | date | 10 |
+----+---------+--------+---------+------+--------+
| 2 | Eve | Julia | qwe | date | 10 |
+----+---------+--------+---------+------+--------+