I have a register of textures where the code of the same is composed of numbers and sometimes with letters, for example:
Código: 2564
Código: C-6551
I would like to leave the search field ready to search for any term searched by the user, such as:
User search for code 6551 the search return C-6551, I tried to do a search using REPLACE
but it did not work very well, what I did was:
SELECT *
FROM cor_textura
WHERE REPLACE(REPLACE(REPLACE(codigo, '.', ''), '-', ''), ' ', '') =
REPLACE(REPLACE(REPLACE('".$edBusca."', '.', ''), '-', ''), ' ', '')
AND cor_textura.status = 1
I tried to substitute the term search by changing ponto
by espaço
, traço
by espaço
and espaço
by espaço
.
The database I'm using is phpMyAdmin and the table structure is this:
'cor_textura' ( 'id_cor_textura' int(10) NOT NULL AUTO_INCREMENT, 'codigo' varchar(150) NOT NULL, 'img' int(10) NOT NULL, 'status' tinyint(5) NOT NULL, PRIMARY KEY ('id_cor_textura') )
As I said, I could not solve my problem.