I have a PDO statement where I need to check the total value of a column which matches a certain ID.
Here's what I have:
$stmt = $DB_con->prepare("SELECT SUM(debit) AS balance FROM pay WHERE rfid=:id");
 $stmt->execute([":id"=>$_GET['id']]);
 $result = $stmt->fetch(PDO::FETCH_ASSOC);
 var_dump(floatval($result['balance']));
Generally, it works but when I added the WHERE clause, it returns 0.
An example of my database entries:
| id | debit | 
|---|---|
| 8755456 | 100 | 
| 9755000 | 88 | 
| 8755456 | 100 | 
| 9755000 | 99 | 
| 8755456 | 50 | 
The above query works without the WHERE statement but returns 0 when the WHERE statement is added. I'm expecting a sum of all the id matches but it returns 0.
When I run the same query in MySQL it shows the right value.
