多表联合查询

tb_Project表:

ID ProjectCreater ProjectPrincipal ...
1 1 2 ...

 

 

tb_User表:

ID UserRealName
1  张三
2  李四

 

 

 

select a.*,b.UserRealName as Creater,c.UserRealName as Principal 
from tb_Project a, tb_User b, tb_User c 
where 
a.ProjectCreater=b.ID and a.ProjectPrincipal=c.ID

 结果: 

tb_Project表:

ID ProjectCreater ProjectPrincipal ... Creater Principal
1 1 2 ... 张三 李四
posted @ 2014-03-21 09:20  Liu66~  阅读(177)  评论(0编辑  收藏  举报