首页 > Linux操作系统 > Linux操作系统 > table connection
Today when i read the sql code, i found one table used two times. I really can't understand that, so i asked my colleague for help. Now i understand with the exam.
Now we have table A about the employee information.The fields are as the following information:
empid sex managerid
1 female 45
2 female 40
And we still have table B about the id and name:
id name
1 lili
2 lucy
40 gao
45 jerry
now we want to get the information about :
empid, sex,manager id and name.
now the query is as the following:
select a.empid,a.sex,b.name,a.managerid,c.name
from a,b, b c
where a.empid=b.id
and a.managerid=c.id
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15225049/viewspace-627067/ ,如需转载,请注明出处,否则将追究法律责任。