Where Mysql search by full word

I have a database and would like to know how I do to 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

Ai wanted to make it return a where by searching for codes

Search: 100

Show: Joao

Search: 9714

Show: Joao, Maria

I did like this:

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

But the 100 searched ta showing all the results that has 100, then returns 88100 and 100

What Can I be doing?

Author: Costamilam, 2018-04-29

1 answers

FIND_IN_SET-serves to find data in a table field that has Comma Separated Values.

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

Example table used:

table

SELECT * FROM usuarios WHERE FIND_IN_SET(100, codigo);

Result

select result

 4
Author: Leo Caracciolo, 2018-04-29 17:11:16