SELECT * FROM products WHERE
serial LIKE '{$ssz}' //exact match, no other serials in row
OR serial LIKE '%,{$ssz}' //match at list end
OR serial LIKE '%,{$ssz},%' //match between other two serials
OR serial LIKE '{$ssz},%' //match at list beginning
This is my perfectly working query, where {$ssz} is a PHP variable to search for.
serial
TEXT columns contain a list of serial numbers, separated with comma.
The serials are unique, but variable length, so "AAB001" and "AB001" are possible.
Maybe it would be faster with regex? Or with a totally different approach?