@i=@i:=@i+rankmember_idmember_idinviteCount `tb_invite_friend` member_id
语句如上,在navicat中能正常运行,但移植到jfinal后运行,报错如下:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT
(@i:=@i+1) rank,
member_id,
COUNT(member_id) inviteCount
FROM
`tb_inv' at line 2
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
应该是无法识别 @i:=@i+1) rank
然后我在 set 前面加了 井号 运行通过,但只有 member_id 和 inviteCount 的数据,没有前面的排序。
这个能解决吗,感谢大神
SELECT
(@i:=@i+1) rank,
member_id,
COUNT(member_id) inviteCount
FROM
`tb_invite_friend`
GROUP BY
member_id
原sql