Secciones

Look for value in a comma separated list field in MySql

Inicio » Artículos » Look for value in a comma separated list field in MySql
La categoría del artículo es
Escrito el 22 September 2015, 15:49


If you have a field formatted as a comma separated list in MySQL and you need to search for those records containing a value in this field, you can use the method find_in_set.


If you have a field formatted as a comma separated list in MySQL and you need to search for those records containing a value in this field, you can use the method find_in_set.

This method returns the index position (starting by 1) where the value was found in the comma separated list field. This is an example:

Mysql:
SELECT * FROM my_table WHERE FIND_IN_SET(the_wanted_value, my_comma_separated_list_field);


Espero tus comentarios...

Ayuda Textile