简体   繁体   中英

Cannot run mysql count (*)

I am trying to run this query

SELECT a.id, count (*) as MovieCount
    FROM actors a
    JOIN roles r ON a.id = r.actor_id 
GROUP BY a.id

but it underlines my * in red and says Error 1064. What could be wrong about the star in parentheses?

The problem (as explained in a comment and deleted answer) is the space after count .

However, you should be aware that you can significantly simplify the query by removing the join :

SELECT r.actor_id, count(*) as MovieCount
FROM roles r
GROUP BY r.actor_id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM