Good all the time of day.

I want to search the table so that it is in several fields (I know how to do this), and most importantly, the search phrase should be searched for “123” or “points”, even if it was in the middle of the text. Can anyone help with sql query?

(Specifically, in my case, the search will be on: 1 integer, 2 varchar, 1 text.)

    1 answer 1

    where `text1` like '%123%' or `text2` like '%123%' 

    Something like this. % in mysql means any sequence of characters.

    • great another question arose: why in the place of the sign "=" (equal), is it worth like? or no difference in this case? - sergey
    • Because this is the syntax of the language. You're not checking for exact match, but for pattern matching. - ling
    • but it is better not to use this search for tables with a large amount of data and high load. - Alex Kapustin
    • shurik, I will be happy with the detailed, reasoned answer))) - sergey
    • It is very long :) The answer to the article pulls. - Alex Kapustin