4
I’m making an SQL that counts how many names in the table start with any letter but an error is being returned:
Column not found: 1054 Unknown column 'A' in 'Where clause'
To the following SQL:
SELECT COUNT(*) FROM author WHERE name LIKE 'A%';
Excommunicating directly in Mysql console works perfectly but when using in PDO error 1054 is returned.
$count = 'SELECT COUNT(*) FROM author WHERE name LIKE \'' . $consulta->letter . '%\'';
echo $count; //Resultado : SELECT COUNT(*) FROM author WHERE name LIKE 'A%'
$stmt = $conn->prepare($count);
Note: I am using PDO
and Mysql
.
@Jorgeb. Amabas the forms didn’t work
– Ricardo
Strange because I get results from
echo
and lap on the console and works– Ricardo
Makes
echo "::$count::";
and put the result here.– Jorge B.
@Jorgeb. ::SELECT COUNT(*) FROM Author WHERE name LIKE 'A%'::
– Ricardo
I really don’t see...
– Jorge B.