Select with like detailed

1

How to perform a select considering that there may not be an exact comparison in the database. I know there is LIKE , but I've already tried and did not have the desired effect.

The problem is next, I have to search the bank for a name that may be missing a letter at the end or at the beginning, for example, the bank may be so JOSIVAN SOUSA but the search entry may be:

  • JOSIVAN SOUS
  • JOSIVAN DE SOUSA
  • OSIVAN SOUSA

And so on.

    
asked by anonymous 31.01.2018 / 17:41

3 answers

2

There is no secret.

Select * from suatabela
where seucampo like '%OSIVAN SOUSA%'
    
31.01.2018 / 17:46
2

MySQL has a set of functions that you can use to work with String, for example SUBSTRING .

  

SELECT * FROM users WHERE 1 = 1       AND       (SUBSTRING (name, 2.16)="OSIVAN DE SOUSA"        OR        SUBSTRING (name, 1.15)="JOSIVAN DE SOUS"        )

    
31.01.2018 / 17:56
2
select * 
  from suatabela
 where seucampo like '%_OSIVAN SOUSA_%'
    
31.01.2018 / 17:52