Hello. Here I can not understand a little search. I am writing a query using LIKE.

If you write this:

select * from 'table' where 'pole1' like 'searchstr'

will not issue anything

If you write this:

select * from 'table' where 'pole1' like '% searchstr%'

gives all the records in the table.

What to do? how to fix the query?

    1 answer 1

    select * from 'table' where 'pole1' like 'searchstr' 

    This is how it searches in the database exactly what you enter. If it differs by at least 1 character, it will not find it. That is, for example, if there is a name “Site No. 1”, and you simply enter “Site”, it will not find it.

     select * from 'table' where 'pole1' like '%searchstr%' 

    This is what the database looks for in such a string, where at least something that you enter to search is present. That is, if there is a "Site number 1", you enter at least "ai", he will find it.

    Do you need something?

    • I did not have time to write that all the rules, I myself can’t just delete the questions myself ... Found a mistake. All the rules - I wish