- MySQL 8 for Big Data
- Shabbir Challawala Jaydip Lakhatariya Chintan Mehta Kandarp Patel
- 237字
- 2021-08-20 10:06:12
LIKE
The LIKE operator provides an easy way to search records with the different patterns in a column. We can use wildcards characters in a query to build various patterns. There are basically two kinds of wildcard which are mostly use. Let's see each of them with the example.
- % (Percentage): Use this wildcard to search zero or more occurrences of any character. Suppose if we want to search users whose username starts with 'a' then we can use this wildcard just like below query.
select * from users where username like 'a%';
In case where we want to search users whose username starts from 'a' and ends with 's' then the query with % wildcard will be like this.
select * from user where username like 'a%s';
- _ (Underscore): Use this wildcard where we want to search records with the pattern where any character can take place where we have specified underscore (_). Suppose we want to search users whose username ends with dmin and we are not sure about the first character. Hence below query will search results whose username's first character can be any but it should end with dmin.
select * from users where username like '_dmin';
Make sure that it would consider exactly one character for one underscore. Hence in this case user with username as "aadmin" will not be considered because query has mentioned only one wildcard character with the underscore.
推薦閱讀
- 國(guó)際大學(xué)生程序設(shè)計(jì)競(jìng)賽中山大學(xué)內(nèi)部選拔真題解(二)
- 案例式C語(yǔ)言程序設(shè)計(jì)
- 無(wú)代碼編程:用云表搭建企業(yè)數(shù)字化管理平臺(tái)
- Python網(wǎng)絡(luò)爬蟲(chóng)從入門到實(shí)踐(第2版)
- 基于Java技術(shù)的Web應(yīng)用開(kāi)發(fā)
- Python計(jì)算機(jī)視覺(jué)編程
- 用Flutter極速構(gòu)建原生應(yīng)用
- bbPress Complete
- Java實(shí)戰(zhàn)(第2版)
- Image Processing with ImageJ
- Getting Started with Python
- Java Hibernate Cookbook
- ROS機(jī)器人編程實(shí)戰(zhàn)
- 深入淺出 HTTPS:從原理到實(shí)戰(zhàn)
- 人件集:人性化的軟件開(kāi)發(fā)