Problems filtering field with LIKE in MySQL [closed]

-1

I have a table that has more than 1 million data that I want to filter through an acronym that can be anywhere in the field's String. The same has BTREE index in MySQL. I'm doing it this way:

select instituicao, count(instituicao)
from base_wos
WHERE instituicao LIKE '%{$Sigla}%' GROUP BY instituicao limit 1250000;

When executing this query, I do not get a return, since it has a non-zero amount in the bank.

I'm using the MySQL Workbench tool.

    
asked by anonymous 13.04.2014 / 02:12

1 answer

3

I was able to solve the problem this way:

select instituicao, count(*)
from base_wos
WHERE instituicao LIKE '%Sigla%' GROUP BY instituicao limit 1250000;

The problem was the syntax of PHP being used in SQL by mistake. Like uses only % as a wildcard, and the substring has to be written literally.

    
13.04.2014 / 02:52