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(*)语法报错。