Fuzzy query with escape contains key character fields

 

In a sql like statement like

select * from user where username like '%nihao%',select * from user where username like '_nihao',

Among them, % is used as a wildcard for multiple wildcards, and _ is used as a wildcard for one wildcard

 

If you really want to query usernames containing % _, you need to make them no longer as wildcards

Escape % _ in like, take _ as an example,

转义前:select * from user where username like '_nihao',

After escaping: select * from user where username like '/_nihao' escape '/', which means that the _ after / is not a wildcard

Guess you like

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