首页 > 代码库 > 两道sql题

两道sql题

     部门周计划表  Hr_DepartPlanWeek :

                DepartMent部门名称,DepartMentID部门ID。

     部门表   g_group:

                gname部门名称,gid部门id

      根据DepartMentID  修改表 g_group的DepartMent字段

update Hr_DepartPlanWeek set DepartMent=t.gname 
from (select gname,gid from g_group left join Hr_DepartPlanWeek on g_group.GId=Hr_DepartPlanWeek.DepartMentID
)t
where t.GId=Hr_DepartPlanWeek.DepartMentID

    T_Content 博客表

    T_ContentType 博客类别表

     同一个博客类别包含多少篇博客

string sql = "select  (select  count(*) from T_Content where FTypeId=T.FID) as num from T_ContentType AS T"


两道sql题