现在我如何从 tm_id=10 的 table2 中选择 project_title
完成这项任务的最佳方法是什么?
SELECT t2.project_title FROM table2 AS t2
JOIN table3 AS t3 ON t3.project_id = t2.project_id
WHERE t3.tm_id = 10;
我认为一个简单的INNER JOIN
就足够了你的需要。
SELECT a.*, c.project_title
FROM Online_team a
INNER JOIN team_project b
ON a.tm_id = b.tm_id
INNER JOIN online_team_projects c
ON b.project_ID = c.project_ID
WHERE a.tm_id = 10
要进一步了解有关联接的更多信息,请访问以下链接:
但是,如果您不需要来自 的任何列Online_team
,则可以将其从联接列表中删除。
SELECT c.project_title
FROM team_project b
INNER JOIN online_team_projects c
ON b.project_ID = c.project_ID
WHERE b.tm_id = 10
使用如下查询
SELECT table2.project_title from table2,table3 where table2.project_id = table3.project_id and table3.tm_id = 10
SELECT
otp.project_title
FROM online_team_projects otp,
team_project tp
WHERE otp.project_id = tp.project_id
AND tp.tm_id = 10
您可以使用这种方法:
SELECT otp.project_title
FROM online_team ot
INNER JOIN online_team_projects otp USING (project_id)
WHERE ot.tm_id = 10