Where Mysql search for complete word

4

I have a database and would like to know how do I search for the data by typing the complete result using where

Example:

ID  NOME  CODIGOS
1  | Joao   | 9714,51,100
2  | Maria  | 50,9714,88100

I wanted to make it return a where by searching for CODES

Search: 100

Show: Joao

Search: 9714

Show: Joao, Maria

I did so:

SELECT * FROM usuarios WHERE codigo like '%100%'

But the 100 searched is showing all results that have 100, so it returns 88100 and 100

What can I be doing?

    
asked by anonymous 29.04.2018 / 18:27

1 answer

4

FIND_IN_SET - Used to find data in a table field that has comma-separated values.

SELECT * FROM nomeTabela WHERE FIND_IN_SET('valorBuscado', nomeColuna);

Example table used:

SELECT*FROMusuariosWHEREFIND_IN_SET(100,codigo);

Result

    
29.04.2018 / 18:53