I have JSON data continuously inserted into a DB table but there are some rows which I need to delete concurrently based on the column value. For eg., I need to delete the rows which have a column value (time_min) of more than 90 minutes.
ID time_min
1 50
2 30
3 91
4 40
5 93
6 95
7 40
Here I need to delete rows containing values more than 90 in time_min column.
This is the current code I'm using.
if($time_min >= 91){
$sql = "truncate table_name";
if ($conn->query($sql) === TRUE) {
echo "Rows Dropped";
}
}
It clearly is deleting the entire table values which mess up in the loading of new values. I would just want the rows that have column value of more than 90 in time_min (column name) to be deleted.
Would appreciate if someone can guide me on this.