1
I have a register of textures where the code is composed of numbers and sometimes with letters, for example:
Código: 2564
Código: C-6551
I would like to have the search field prepared to perform the search for any term searched by the user, such as:
User searches by code 6551 the search return C-6551, tried to make a search using the REPLACE
but it didn’t go very well, what I did was this:
SELECT *
FROM cor_textura
WHERE REPLACE(REPLACE(REPLACE(codigo, '.', ''), '-', ''), ' ', '') =
REPLACE(REPLACE(REPLACE('".$edBusca."', '.', ''), '-', ''), ' ', '')
AND cor_textura.status = 1
I tried to replace the term search by changing ponto
for espaço
, traço
for espaço
and espaço
for 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`) )
Like I said, I couldn’t solve my problem.
Hello @David, it was one of the tests I did and the result was not correct, did not return anything.
– adventistapr
Which Bank is using? What is the structure of the Table
cor_textura
, so I can simulate.– David
I added an example in Sqlfindle.
– David
Hi @David, I had made an error in my SQL, I forgot to put the '$' in the variable, thanks for the help.
– adventistapr