people_table
id project_id comp_id people_name
1 13 1 john
2 16 2 rob
3 18 1 jack
4 18 2 lee
company_table
id project_id comp_name
1 21 axn
2 13 ibm
3 15 anz
答案 0 :(得分:1)
你需要这个:
SELECT A.*,B.*
FROM people_table as A
INNER JOIN company_table as B
ON A.project_id = B.project_id
你应该查看sqlfiddle:
答案 1 :(得分:0)
尝试使用INNER JOIN
SELECT P.*,C.*
FROM people_table P
INNER JOIN company_table C ON P.project_id = C.project_id
WHERE P.project_id = $your_project_id;
答案 2 :(得分:0)
请尝试以下。
select * from people_table p,company_table c where p.projectID=c.projectID
这会显示project_ID列两次。因此,您可以使用distinct关键字来获取一个项目ID列。