当前位置: 代码迷 >> J2EE >> 求hql语句解决方法
  详细解决方案

求hql语句解决方法

热度:17   发布时间:2016-04-22 03:01:42.0
求hql语句
表结构 如下

table:class  
id classid classname 
1 2001 计算机2001
2 2002 计算机2002
3 2003 计算机2003
4 2004 计算机2004
5 2005 计算机2005

table:member
id classid userid
1 2001 001
2 2001 002
3 2002 003 
4 2002 004
5 2002 005
6 2003 006
7 2003 007
8 2003 008

求结果
classid count classname 
2001 2 计算机2001
2002 3 计算机2002
2003 3 计算机2003
2004 0 计算机2004
2005 0 计算机2005

hql语句。谢谢
我只能写出member中有classid的语句


------解决方案--------------------
SQL code
select t1.classid,(select count(t.id) from Member t where t.classid = t1.classid),classname from Class t1
  相关解决方案