Get the App
SLTechnology News&Howtos  ›  Database  › 

[record] misunderstandings about the use of wildcards when mysql uses like to match data

Shulou Source: shulou.com Published: 2022-06-01 13:43:13 09月29日 Update

-- "_" in this sql is a wildcard character that matches any single character, so the filtered data contains the data at the beginning of test:

Select * from live_class where title like 'test_%'

Solution:

-- the following two implementations have the same effect (personal preference for the second, which is more in line with the usage habits of background development):

Select * from live_class where title like 'test/_%' escape' /'; select * from live_class where title like 'test\ _%'

Note: the difference between "_" and "%" is that the wildcard "_" matches any single character, while "%" is any character.

Tags: Data wildcards words personal background characters beginning effects solutions development misunderstandings Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Linux Redmi Microsoft