Search only a random part inside a code with select in mysql

1

The problem is as follows, I have the concatenated code, I need to see this concatenated code if part of it is in the table, ie by putting field 1 and field 2 > with PHP, before searching the table, a variable brings me this preprogrammed, I will have the code:

212e5a8817f6f40da398b9baddddecd28abff2df24b6816fabdf2ff4e64dfd00b192d7f0a2bed8b0b7ab992312978885b4cd079a9d9ea5c955fce646635fa2e2n3fbrqv345d4231qepklnt3i73

I have this code, I need to put this in like so it brings me this code by finding them in two different fields, that is in the field A of my table I have

212e5a8817f6f40da398b9baddddecd28abff2df24b6816fabdf2ff4e64dfd00b192d7f0a2bed8b0

and field B I have

b7ab992312978885b4cd079a9d9ea5c955fce646635fa2e2n3fbrqv345d4231qepklnt3i73

and in the variable I have

212e5a8817f6f40da398b9baddddecd28abff2df24b6816fabdf2ff4e64dfd00b192d7f0a2bed8b0b7ab992312978885b4cd079a9d9ea5c955fce646635fa2e2n3fbrqv345d4231qepklnt3i73

I have to search this in MySQL and bring me these two fields, is that possible?

EDIT

I found it, but I found it Basic with concat_ws

select * from tabela where concat_ws('',campo1,campo2) 
like '%n3fbrqv345d4231qepklnt3i73212e5a8817f6f40da398b9baddddecd28abff2df24b6816fabdf2ff4e64dfd00b192d7f0a2bed8b0b7ab992312978885b4c%';
    
asked by anonymous 09.07.2015 / 01:04

2 answers

1

If the column type is: CHAR or VARCHAR it is sure that LIKE will work perfectly:

SELECT * FROM 'tabela' WHERE campo LIKE “%n3fbrqv345d4231qepklnt3i73%”

Also try using the function for strings INSTR :

SELECT * FROM 'tabela' WHERE INSTR("212e5a8817f6f40da398b9baddddecd28abff2df24b6816fabdf2ff4e64dfd00b192d7f0a2bed8b0b7ab992312978885b4cd079a9d9ea5c955fce646635fa2e2n3fbrqv345d4231qepklnt3i73", “%n3fbrqv345d4231qepklnt3i73%”);
    
09.07.2015 / 01:26
0

Have you checked that the problem is not case sensitive ?

To solve this, just add LOWER , which will turn everything into a tiny one.

$busca = strtolower($busca);
$resultado = $mysqli->query("SELECT * FROM tabela WHERE LOWER(campo) LIKE '%". $busca . "%'");
    
09.07.2015 / 01:35