1
I have a field that gathers values that are sequences of numbers separated by space and comma, such as: "1 , 2 , 3 , 23 , 41 , 54"
I was using SQL inside PHP to find a number inside this field with LIKE, but the way I did, if I wanted to find only 5, for example, it would find 54 in the field I wrote up there, and that would be wrong.
$sql = mysql_query("select nm_linha from linhas where cidades_origem like '%$cod_cidades%' and ida like '%$cod_bairros%' and cidades_destino like '%$cod_cidades2%' and ida like '%$cod_bairros2%'");
cities_origin, going and destination cities are bank columns; $cod_cities, $cod_cities2, $cod_neighborhoods and $cod_bairros2 are PHP variables with the numbers I want to find.
How can I make the query to search the number in question preceded and followed by a space, and before and after these spaces may exist any content (%)?
In a perfect solution, you have to normalize this field in other tables.
– Édipo Costa Rebouças