gal-s
9/26/2019 - 11:55 AM

check substring in sql query

simple form
where db.field LIKE '%john%';

advanced form - checks multiple options (using php)
in this example - check wheathre the categoryID in the database is one of the categoryIDs in $categoryIDs
$categoryIDs = "10,20,50,80";
where (',$categoryIDs,' LIKE CONCAT('%,',db.categoryID,',%'))";


for more like patterns:
https://www.w3schools.com/sql/sql_like.asp