SQL Count返回0

I have been trying to count the number of paths present in my table.

enter image description here

I am trying the following query

$db_con->query("SELECT COUNT(path) FROM mytable WHERE username='Rbiaali' AND path='C:\MAMP\htdocs\files\Rbiaali\9-5-2019 01 55 AM.zip'")->fetchColumn();

Also even if i use the below it is returning the same value: 0

path LIKE 'C:\MAMP\htdocs\files\Rbiaali\9-5-2019 01 55 AM.zip%'

As in the table, we can see that there are 6 entries with the path.

You need to escape the backslashes, because backslash is the escape character in MySQL. \f is a form-feed character.

$db_con->query("SELECT COUNT(path) FROM mytable WHERE username='Rbiaali' AND path='C:\\MAMP\\htdocs\\files\\Rbiaali\\9-5-2019 01 55 AM.zip'")->fetchColumn();

If you're getting the path from a variable, use a prepared statement:

$stmt = $db_con->prepare("SELECT COUNT(path) FROM mytable WHERE username=:user AND path=:path");
$stmt->execute([":user" => $u, ":path" => $p]);
$stmt->fetchColumn();

Backslash \ is causing the problem.

Run the $path variable through addslashes() method.

addslashes() documentation

try to di this

$result = mysqli_query($con,"SELECT COUNT(path) FROM mytable WHERE username='Rbiaali' AND path='C:\MAMP\htdocs\files\Rbiaali\9-5-2019 01 55 AM.zip'");
$value = mysqli_fetch_object($result);
$data = $value->id;