I have a mysql table that has a colum开发者_开发技巧n for "date time" in TIMESTAMP format. Is there a way to group the rows by day using that column? And in an SQL query, not grouping them in php.
Assuming your column is one of the Date and Time types:
SELECT ... GROUP BY DATE(`datetimecolumn`)
GROUP BY TO_DAYS(`datetime_column`)
If you mean you have a standard DATETIME column, you can group by using one of the functions described here.
For instance:
GROUP BY DATE(datetime_column);
If you actually have a TEXT or VARCHAR column (your answer doesn't specify), then you'll need to convert it to to a date first:
GROUP BY DATE(STR_TO_DATE(datetime_column));
精彩评论