+----+---------------+--------------------+--+
| id | user_id | createAt | |
+----+---------------+--------------------+--+
| 1 | 1 |2022-05-12 11:36:44 | |
| 2 | 1 |2022-05-12 11:36:50 | |
| 3 | 1 |2022-05-12 11:37:01 | |
| 4 | 2 |2022-05-15 19:22:20 | |
| 5 | 2 |2022-05-15 19:22:25 | |
| 6 | 2 |2022-05-15 19:22:27 | |
| 7 | 3 |2022-05-16 14:05:44 | |
| 8 | 3 |2022-05-16 14:05:44 | |
+----+---------------+--------------------+--+
I have a table like the one above. There are about 100 thousand such records in the table. I want to delete the parts with the same user_id and same date from this table (I want it to be deleted even if there is a +- 5 minutes difference in the date part). How can I do that. I tried many ways but failed. Sorry for my bad english. Thank you.
Edit: I tried this code but not work with +-5 min
$sql = "SELECT id, user_id, DATE_FORMAT(createAt,'%Y-%m-%d %H:%i') as month_date FROM mytable WHERE user_id= '".$_GET['accountId']."' GROUP BY month_date HAVING COUNT( * ) >1";
if ($result=mysqli_query($con,$sql)) {
while($row = mysqli_fetch_array($result)){
echo $row["month_date"]. " ". $row["user_id"]. "<br>";
}
}