I use group by
with a count function in LARAVEL 4.2. When I tried to use LIKE
in the same query, it gave me the error Invalid use of group function
, as we can't use like
with group by
. How can I solve this?
Asked
Active
Viewed 161 times
0

Arnaud
- 7,259
- 10
- 50
- 71

Khurram Satti
- 44
- 4
1 Answers
1
You can't use Mysql aggregate function with group
& like
both together you have to use having
instead of like
.
Check here MySQL :: MySQL 5.0 Reference Manual :: 12.16.3 MySQL Handling of GROUP BY
and here: A similar SO question answer

Community
- 1
- 1

ARIF MAHMUD RANA
- 5,026
- 3
- 31
- 58
-
I can use like and group by together but when you use an aggregate function with group by then MySQL throws an error. – Khurram Satti Sep 03 '15 at 07:32
-
@KhurramSatti yes you are right my mistake, changed answer. – ARIF MAHMUD RANA Sep 03 '15 at 07:39