like '%%' query in SQL

One, when we use like normally, this is a fuzzy query with two conditions

select  *From Test where UserName like '%m%' and UserName like '%a%'

Two, but at this time, if I only pass one condition in the code, and the other condition is empty, what is the result?

select  *From Test where UserName like '%m%' and UserName like '%%'

The result here is that like '%%' defaults to querying all, so only the data that meets the conditions like '%m%' will be queried. If there is no like '%m%', it will be the same as the result of select *From Test of

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324909204&siteId=291194637