Home > Database > Mysql Tutorial > body text

Does mysql support like?

青灯夜游
Release: 2020-10-06 07:42:04
Original
2100 people have browsed it

mysql supports like, which can match any multi-character or fuzzy match any single character, and will be used in combination with "%" and "_"; for example, "%a" matches data ending with a, " %a%" matches data containing a, "_a_" matches data with three digits and the middle letter is a, etc.

Does mysql support like?

Using Like in MySQL for fuzzy query

The so-called "fuzzy query" corresponds to the "precise query" Come. For example, if we want to query whether a field value is equal to 1, we can write "where column=1" in the SQL statement. This is an exact query. Precise query is very simple and easy to understand, but we often use fuzzy query. For example, I want to query a user from the user table, but I can't remember his name. I only know that there is "Hong" in his name. words, then fuzzy query comes in handy.

like match/fuzzy match, will be used in combination with % and _.

'%a'     //以a结尾的数据
'a%'     //以a开头的数据
'%a%'    //含有a的数据
'_a_'    //三位且中间字母是a的
'_a'     //两位且结尾字母是a的
'a_'     //两位且开头字母是a的
Copy after login

Query information starting with the java field.

SELECT * FROM position WHERE name LIKE 'java%';
Copy after login

Query information containing java fields.

SELECT * FROM position WHERE name LIKE '%java%';
Copy after login

Query information ending with java field.

SELECT * FROM position WHERE name LIKE '%java';
Copy after login

Recommended tutorial: mysql video tutorial

The above is the detailed content of Does mysql support like?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!