WHERE CONCAT(',', sector_id_csv, ',') LIKE '%,$sectorId,%'
or
WHERE FIND_IN_SET('$sectorId', sector_id_csv);
This ensures that your query will only return rows with the sector identifier in the specified field. Provided that sector identifiers in this field are separated by a comma.
Any query using LIKE or FIND_IN_SET will be slow because it cannot use indexes. Please consider placing all sector identifiers in a separate table.
Also, for security reasons, remember that $ sectorId is a number, dropping it like this:
$sectorId = (int)$sectorId;
before using it in the request.
source share