I have a mysql query using PDO, where i would like to use the LIKE statement to search my database for values.
I am currently using the query
$selectdp = $connection->prepare(
"SELECT `FilePath`,`ItemPicID`,`Extension`
FROM `ItemPics`
WHERE `BusinessID`=:bizid
AND `ItemID`=:itemid
AND `FilePath` LIKE :search ");
with
$selectdp->bindValue(":search",'%DP');
but i am getting the error
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%DP' ....
Things i've tried in the query
- LIKE=:search
- LIKE CONCAT('%'.:search)
I've taken a look at
implement LIKE query in PDO and How prepare statement with bindvalue and %? but nothing seems to be working.