0

Tried:

SELECT DATE(`time`), HOUR(`time`), COUNT(*) 
FROM `table` 
GROUP BY DAY(`create_time`), HOUR(`create_time`)

This is work on mysql but fail on php, wonder know why and how to solve it

Thanks!

user3783243
  • 5,368
  • 5
  • 22
  • 41
suki
  • 5
  • 5
  • I use php 7 and mysql 5 – suki Jul 07 '20 at 03:12
  • Please tell us what the error is. Also provide your real code. Your `group by` should have columns in your `select` query. – user3783243 Jul 07 '20 at 03:16
  • Sorry, my bad, the column in select and group by are the same, i just doing the sql but show http 500 error – suki Jul 07 '20 at 03:21
  • Please provide the actual PHP code you are using, actual SQL, and the error message(s). We can't help you without that information. – user3783243 Jul 07 '20 at 03:22
  • after looking for the error message, found that the problem is 'sql_mode=only_full_group_by', and i've solved it, thanks, @user3783243 – suki Jul 07 '20 at 03:35
  • Depending on how you solved it may want to look at https://stackoverflow.com/questions/45484068/what-are-the-benefits-of-only-full-group-by-mode. – user3783243 Jul 07 '20 at 03:42
  • Note that in general the GROUP BY should include all the non-aggregated columns in the SELECT. You query includes none of them. – Strawberry Jul 07 '20 at 06:09

0 Answers0