Home Database Mysql Tutorial sql like 通配符[] %实例教程

sql like 通配符[] %实例教程

Jun 07, 2016 pm 05:46 PM
Wildcard

sql like 通配符[] %实例教程

sql like 通配符[] %实例教程

注意:不管是mysql,sql server,dbms等在like通配符上都不支持text,ntext 只支持

char,varchar,nvarchar等哦。

$s = "select * from test where dmulplace like '%$city%'"
id   uid   parttime  city
211 7117   全职   长沙,益阳  
5510 12419 全职            
5511 12420 全职   东莞,     
209 7115   全职   长沙      

得出的结果记录二条

211 7117   全职   长沙
209 7115   全职   长沙

下面看看简单的sql like 通配符 说明
_    与任意单字符匹配
 
%    与包含一个或多个字符的字符串匹配
 
[ ]  与特定范围(例如,[a-f])或特定集(例如,[abcdef])中的任意单字符匹配。
 
[^]  与特定范围(例如,[^a-f])或特定集(例如,[^abcdef])之外的任意单字符匹配


 使用like比较字,加上SQL里的通配符,请参考以下:
a.. LIKE 'Mc%' 将搜索以字母 Mc 开头的所有字符串(如 McBadden)。

b.. LIKE '%inger' 将搜索以字母 inger 结尾的所有字符串(如 Ringer、
Stringer)。

c.. LIKE '%en%' 将搜索在任何位置包含字母 en 的所有字符串(如 Bennet、
Green、McBadden)。

d.. LIKE '_heryl' 将搜索以字母 heryl 结尾的所有六个字母的名称(如 Cheryl、
Sheryl)。

e.. LIKE '[CK]ars[eo]n' 将搜索下列字符串:Carsen、Karsen、Carson 和 Karson
(如 Carson)。

f.. LIKE '[M-Z]inger' 将搜索以字符串 inger 结尾、以从 M 到 Z 的任何单个字
母开头的所有名称(如 Ringer)。

g.. LIKE 'M[^c]%' 将搜索以字母 M 开头,并且第二个字母不是 c 的所有名称(如
MacFeather)。

关键字:sql like,通配符

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the oracle wildcards? What are the oracle wildcards? Nov 08, 2023 am 10:02 AM

Oracle wildcard characters include "%", "_", "[]" and "[^]". Detailed introduction: 1. The wildcard character "%" means matching any character, including zero characters. Using the wildcard character "%" in Oracle can implement fuzzy query. When the wildcard character "%" is used in the query statement, the query will return all characters matching the specified character. Pattern matching string; 2. The wildcard character "_" means matching any single character. In Oracle, the wildcard character "_" can be used to achieve exact matching. When using wildcard characters in query statements, etc.

What are the regular expression wildcards? What are the regular expression wildcards? Nov 17, 2023 pm 01:40 PM

Regular expression wildcards include ".", "*", "+", "?", "^", "$", "[]", "[^]", "[a-z]", "[A-Z] ","[0-9]","\d","\D","\w","\W","\s&quo

What are the wildcard characters in word? What are the wildcard characters in word? Jan 22, 2024 pm 04:03 PM

Word wildcard characters include "?", "*", "[]", "!", "%", etc. Detailed introduction: 1. Question mark (?): indicates matching any single character. For example, "c?t" can match words such as "cat" and "cut"; 2. Asterisk (*): indicates matching zero or more characters. For example, "colr" can match words such as "color" and "colour"; 3. Square brackets ([]): means matching any character within the square brackets. For example, "[aeiou]" can match any vowel; 4. exclamation point, etc.

What do the wildcard characters * and ? mean when searching for files? What do the wildcard characters * and ? mean when searching for files? Jul 25, 2022 am 11:43 AM

The wildcard character "*" can represent any string and can match zero, single or multiple characters; while the wildcard character "?" only represents a single string, and this word must exist. Wildcard is a special statement, mainly including asterisk "*" and question mark "?", used to fuzzy search files; the number of matches for "*" is not limited, while the number of matching characters for "?" is limited. When looking for a folder, you can use it to replace one or more real characters; when you don't know the real characters or you are too lazy to enter the full name, you often use wildcards to replace one or more real characters.

Generic wildcards in Java functions: upper and lower bounds Generic wildcards in Java functions: upper and lower bounds Apr 25, 2024 pm 04:18 PM

In Java, generic wildcards allow generic types to be represented without specifying concrete types. Upper limit wildcard (

What is the difference between wildcard characters * and ? What is the difference between wildcard characters * and ? Aug 11, 2023 pm 01:20 PM

The wildcards * and ? have some differences in usage and matching range. Specific differences: 1. In terms of matching range, the wildcard * can match any length of character sequence, including letters, numbers, punctuation marks, spaces, etc., while the wildcard ? can only match one character; 2. In terms of usage, the wildcard * is used Fuzzy matching can match multiple characters or character sequences. The wildcard character ? is used for exact matching and can only match one character.

Learn from scratch: Master wildcards in Linux commands Learn from scratch: Master wildcards in Linux commands Mar 16, 2024 pm 12:18 PM

Learn from scratch: Master wildcard characters in Linux commands In Linux systems, wildcard characters are special characters used to match file names. Mastering these wildcards can help us locate and operate files on the command line more efficiently. This article will focus on several commonly used Linux wildcard characters, with specific code examples, hoping to help beginners better understand and use these wildcard characters. 1. Asterisk (*) The asterisk wildcard represents zero or more arbitrary characters and can match any long string. Here is an example: ls

Common CSS selector wildcard examples to master Common CSS selector wildcard examples to master Dec 26, 2023 am 09:00 AM

To master common CSS selector wildcard examples, specific code examples are required. CSS selectors are a very important part of web development. They allow us to select and style HTML elements based on different element attributes. Among CSS selectors, wildcards are a very useful selector that can match any type of HTML element. In this article, we will introduce commonly used CSS wildcards and provide specific code examples. Wildcard (*) The wildcard "*" represents selecting all HTML elements. It can be used to set all

See all articles