Whether the mysql database supports like
This article mainly introduces whether the mysql database supports like or not, which can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
Mysql supports like,like to vaguely match any multi-character match or any single character, which will be used in combination with "%" and "_"; for example, "% a" matches data ending in a, "% a%" matches data containing a, "_ a_" matches data with three digits and the middle letter is a, and so on.
Fuzzy query using Like in MySQL
The so-called "fuzzy query" corresponds to "precise query". 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, which is the exact query. Precise queries are easy to understand, but we often use fuzzy queries. For example, I want to look up a user from the user table, but I can't remember to clean up his name. I only know that there is a word "Hong" in his name. then the fuzzy query comes in handy.
Like matching / fuzzy matching, will be used in combination with% and _.
'% a' / / data ending with a' a%'/ / data starting with a'% a%'/ / containing three digits of a with the middle letter of'_ a'/ / two digits of an and ending with two digits of'a'/ / with the beginning of a
Query for information that begins with the java field.
SELECT * FROM position WHERE name LIKE 'java%'
Query information that contains the java field.
SELECT * FROM position WHERE name LIKE'% java%'
Query the information that ends with the java field.
SELECT * FROM position WHERE name LIKE'% java'; Thank you for reading this article carefully. I hope it will be helpful for everyone to share whether the mysql database supports like content. At the same time, I also hope that you will support it, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!