我想每天从数据库中获取记录。我已将datetime存储在date列中,因此我想仅使用日期而不是时间来获取。
1.我尝试使用GROUP BY date
,但要避免这种情况也需要花费时间,因此我也尝试了GROUP BY DATE(date)
和GROUP BY (CAST (date AS DATE))
,但这将所有记录合并为一行,未按日期显示不同的行。
我应该如何做到这一点
这是我尝试的代码
$select_pins = mysqli_query($conn,"SELECT COUNT(*) AS total, DATE(date) AS date, date, user_name, FROM created_epins GROUP BY CAST (date AS DATE)");
我希望结果应该是
Sr. No. User Name Quantity Date
1 Someone 3 10/05/2019 03:40:32
2 Anyone 5 11/05/2019 09:20:12
但这就是它的输出结果
Sr. No. User Name Quantity Date
1 Someone 8 10/05/2019 03:40:32