SQL和JPA的一个互斥写法

MYSQL:

select count(*), l.xxx, l.yy, l.zz
from ll l, tt t
where t.lid = l.id 
group by t.lid ;

JPA:

@Query(value = "select l.id, count(t), l.xx, l.yy, l.zz
            "from ll l, tt t \n" +
            "where t.lid = l.id \n" +
            "group by t.lid")
    List<Object> getlsAndCount();

以上为正确写法。

但是,

sql中使用count(t)报语法错;jpa代码里写count(*)语法报错。


版权声明:本文为github_34709302原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。