java.sql.SQLException: 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 'count(e.id) as empcount from level as l left join customer as c on c.levelid = l' at line 1 SQL语句:
private String levGetAll_sql = "select l.Recid, l.id, l.name, l.re "
+ "count(l.id) as empcount from level as l "
+ "left join customer as c on c.levelid = l.id "
+ "group by l.id";

解决方案 »

  1.   


    count(l.id) 后面应该有个分组函数
      

  2.   

    去掉count(l.id) as empcount 
    使用count聚合函数时不能同时查询其他字段,除非此字段在group by 中出现
      

  3.   

    你已经有group by了呀。
    那count(l.id) as empcount 可以放着,但select中的其他字段必须去掉,要么在group by中对此字段分组
      

  4.   

    是用了group by的话,其他要显示出来的字段必须也能够分组,否则无法执行。
      

  5.   

    这个是啥数据库?怎么没看懂这个sql呢。