Reputation: 23
I don't know why this query ...
SELECT COUNT(*),* FROM table1 WHERE .. GROUP BY column1
return a syntax error, but ...
SELECT *,COUNT(*) FROM table1 WHERE .. GROUP BY column1
... returns normal data.
Is this a bug?
Upvotes: 0
Views: 62
Reputation: 11413
The Mysql documentation for SELECT
says:
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 ...
So, in your case use this syntax:
SELECT COUNT(*), table1.* FROM table1 WHERE .. GROUP BY column1
Upvotes: 2