sql 转换成hql 我想把这条SQL 语句专程HQL 大侠们帮帮我。
selectguanjianci,count(wenzhang_id)ascountfrom(selectguanjianci,wenzhang_IDfromj_guan...
select guanjianci,count(wenzhang_id) as count
from (select guanjianci,wenzhang_ID
from j_guanjianci gjc,J_wenzhang wz
where (wz.biaoti_cn like '%研究%' or guanjianci_cn like '%研究%'
or zuozhe_cn like '%研究%' and DateDiff(month,chubanriqi,getDate())<=3 and gjc.wenzhang_id=wz.id )
group by guanjianci,wenzhang_ID)m
group by guanjianci
order by count(wenzhang_id) desc
j_guanjianci 的类是KeyWord
J_wenzhang 的类是Article 展开
from (select guanjianci,wenzhang_ID
from j_guanjianci gjc,J_wenzhang wz
where (wz.biaoti_cn like '%研究%' or guanjianci_cn like '%研究%'
or zuozhe_cn like '%研究%' and DateDiff(month,chubanriqi,getDate())<=3 and gjc.wenzhang_id=wz.id )
group by guanjianci,wenzhang_ID)m
group by guanjianci
order by count(wenzhang_id) desc
j_guanjianci 的类是KeyWord
J_wenzhang 的类是Article 展开
1个回答
展开全部
select gjc.guanjianci,count(gjc.wenzhang_id) as count
from (select gjc.guanjianci,gjc.wenzhang_ID
from KeyWord gjc,Article wz
where (wz.biaoti_cn like '%研究%' or wz.guanjianci_cn like '%研究%'
or wz.zuozhe_cn like '%研究%' and wz.DateDiff(month,chubanriqi,getDate())<=3 and gjc.wenzhang_id=wz.id )
group by wz.guanjianci,wz.wenzhang_ID)
group by wz.guanjianci
order by count(wz.wenzhang_id) desc
我改了下,你对看表对应的字段是否是对了的!
from (select gjc.guanjianci,gjc.wenzhang_ID
from KeyWord gjc,Article wz
where (wz.biaoti_cn like '%研究%' or wz.guanjianci_cn like '%研究%'
or wz.zuozhe_cn like '%研究%' and wz.DateDiff(month,chubanriqi,getDate())<=3 and gjc.wenzhang_id=wz.id )
group by wz.guanjianci,wz.wenzhang_ID)
group by wz.guanjianci
order by count(wz.wenzhang_id) desc
我改了下,你对看表对应的字段是否是对了的!
追问
HQL 语句的from后面必须是实体类。你确定对嘛?
追答
from 后面是必须是实体类,而且必须大小写要区分的!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询