数据库sql语句转成hql语句
数据库语句:select*fromgoodsWHEREgoods.goods_idin(selecttop4bid.goods_idfrom(selectbid.good...
数据库语句 :
select * from goods WHERE goods.goods_id in(select top 4 bid.goods_id from (select bid.goods_id,count(*) as s from bid group by bid.goods_id)bid order by s desc )
两表关联 bid表的外键goods_id 是 goods表
我转成这个hql :
from Goods goods WHERE goods.goodsId in(select top 4 Bid.goods from (select Bid.goods,count(*) as s from Bid group by Bid.goods)Bid order by s desc )";
但是用不了 。。
就算我分解出来了这句 :
select bid.goods from Bid bid group by bid.goods
用上group 就会出错
大侠们耐心帮我分析一下吧 谢了
hql 里面不能用 group by ? 展开
select * from goods WHERE goods.goods_id in(select top 4 bid.goods_id from (select bid.goods_id,count(*) as s from bid group by bid.goods_id)bid order by s desc )
两表关联 bid表的外键goods_id 是 goods表
我转成这个hql :
from Goods goods WHERE goods.goodsId in(select top 4 Bid.goods from (select Bid.goods,count(*) as s from Bid group by Bid.goods)Bid order by s desc )";
但是用不了 。。
就算我分解出来了这句 :
select bid.goods from Bid bid group by bid.goods
用上group 就会出错
大侠们耐心帮我分析一下吧 谢了
hql 里面不能用 group by ? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询