ITPub博客

首页 > Linux操作系统 > Linux操作系统 > table connection

table connection

原创 Linux操作系统 作者:susie0409 时间:2010-02-08 22:04:45 0 删除 编辑

  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/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: useful website
请登录后发表评论 登录
全部评论

注册时间:2009-09-30

  • 博文量
    115
  • 访问量
    305731