Unknown column error in this COUNT MySQL statement?

后端 未结 4 514
情书的邮戳
情书的邮戳 2021-01-20 01:11

Error is

Unknown column \'num\' in \'where\' clause

SELECT COUNT(*) AS num, books_bookid
FROM bookgenre_has_books
WHERE         


        
4条回答
  •  渐次进展
    2021-01-20 01:39

    WHERE clause cant see aliases,use HAVING.

    It is not allowable to refer to a column alias in a WHERE clause, because the column value might not yet be determined when the WHERE clause is executed

    http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html

提交回复
热议问题