此COUNT个MySQL语句中的未知列错误? [英] Unknown column error in this COUNT MySQL statement?
本文介绍了此COUNT个MySQL语句中的未知列错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误是
"where"子句中的未知列"num"
Unknown column 'num' in 'where' clause
SELECT COUNT(*) AS num, books_bookid
FROM bookgenre_has_books
WHERE num > 10
GROUP BY books_bookid
我做错了什么?谢谢.
推荐答案
WHERE
子句无法看到别名,请使用HAVING
.
WHERE
clause cant see aliases,use HAVING
.
不允许在WHERE子句中引用列别名,因为执行WHERE子句时可能尚未确定列值
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
这篇关于此COUNT个MySQL语句中的未知列错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文