我不知道为什么这个查询...
SELECT COUNT(*),* FROM table1 WHERE .. GROUP BY column1
返回语法错误,但是...
SELECT *,COUNT(*) FROM table1 WHERE .. GROUP BY column1
...返回正常数据。
这是一个错误吗?
最佳答案
Mysql documentation对于 SELECT
说:
Use of an unqualified * with other items in the select list may produce a parse error. To avoid this problem, use a qualified tbl_name.* reference
SELECT AVG(score), t1.* FROM t1 ...
因此,在您的情况下使用以下语法:
SELECT COUNT(*), table1.* FROM table1 WHERE .. GROUP BY column1
关于mysql - MySQL 命令 SELECT 的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12029766/