官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 陇川县| 峨眉山市| 海宁市| 马鞍山市| 方正县| 沙湾县| 富阳市| 柳林县| 杭锦后旗| 大同县| 宕昌县| 赤水市| 凌海市| 博野县| 玉溪市| 鹰潭市| 安阳县| 建宁县| 彭泽县| 息烽县| 大兴区| 上杭县| 精河县| 巴林右旗| 洪洞县| 洞头县| 常山县| 临桂县| 东莞市| 定州市| 平和县| 北碚区| 兖州市| 阿瓦提县| 高台县| 长治市| 邯郸县| 利津县| 梅州市| 伊春市| 高阳县|