我在datagrid要显示
部门  人数  工资
有三个数据表
部门表(depart)  字段  departid  depart
人员表(person)  字段  person  departid
工资表(salary)  字段  person  salary请问我的sql语句要怎么写

解决方案 »

  1.   

    最简单 办法是自己是SQL中建个视图,把这三个表关联在一起,它会自动生成SQL语句的,这样你就能得到相应的SQL语句了,当然你也可以直接用这个视图。
      

  2.   

    呵呵,能不能有谁能写个sql语句指点下啊,我也知道关联啊,问题怎么写啊
      

  3.   

    部门  人数(人员)  工资
    有三个数据表
    部门表(depart)  字段  departid  depart
    人员表(person)  字段  person  departid
    工资表(salary)  字段  departid  salary用departid作为索引,这样就简单查询了
    select DT.depart,PN.person,SY.salary 
    from depart as DT,person as PN,salary as SY
    where DT.departid=PN.departid and PN.departid=SY.departid
    order by DT.depart
      

  4.   

    不知道我给你的SQL文是不是你想要的
      

  5.   

    select DT.depart,(select count(*) from PN where PN.departid=DT.depart),SY.salary 
    from depart as DT,salary as SY
    where DT.departid=PN.departid and PN.departid=SY.departid
    order by DT.depart