首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

求hql语句解决方法

2012-01-10 
求hql语句表结构 如下table:classid classid classname12001计算机200122002计算机200232003计算机2003420

求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 

热点排行