Home Database Mysql Tutorial 以前编写Like谓词被忽略的使用方法_MySQL

以前编写Like谓词被忽略的使用方法_MySQL

Jun 01, 2016 pm 02:05 PM
l where match neglect us identification write

我们知道在使用SQL语句编写查询时会用到SELECT语句。它的基本结构如下:

SELECT ... ... FROM ... ... WHERE ... ... ORDER BY ... ...

在使用WHERE条件子句时我们知道可以通过LIKE关键字进行模糊查询,而且我们也知道可以使用通配符实现这个。我们通常知道的通配符有下划线_和百分号%。其实我们还有其它的查询匹配可用,只是我们不经常使用而忽略了它们。被我们忽略的就是匹配特定范围[]和匹配特定范围之外的[^]两个。

下面大家先看看在Microsoft SQL Server中定义的通配符:

通配符 说明

_(下划线) 与任意单字符匹配

% 与包含一个或多个字符的字符串匹配

[ ] 与特定范围(例如,[a-f])或特定集(例如,[abcdef])中的任意单字符匹配。

[^] 与特定范围(例如,[^a-f])或特定集(例如,[^abcdef])之外的任意单字符匹配。

下面我们列出一些事例去说明这些通配符的使用。


WHERE FirstName LIKE '_im' 可以找到所有三个字母的、以 im 结尾的名字(例如,Jim、Tim)。


WHERE LastName LIKE '%stein' 可以找到姓以 stein 结尾的所有员工。


WHERE LastName LIKE '%stein%' 可以找到姓中任意位置包括 stein 的所有员工。


WHERE FirstName LIKE '[JT]im' 可以找到三个字母的、以 im 结尾并以 J 或 T 开始的名字(即仅有 Jim 和 Tim)


WHERE LastName LIKE 'm[^c]%' 可以找到以 m 开始的、后面的(第二个)字母不为 c 的所有姓。

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 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)

Li Auto's L series welcomes new member: Li Auto L6 positioned as a medium-sized five-seat SUV Li Auto's L series welcomes new member: Li Auto L6 positioned as a medium-sized five-seat SUV Jul 02, 2023 pm 11:57 PM

According to news on June 30, Li Auto’s L series models, including L7, L8 and L9, have achieved considerable sales results in their respective price ranges. However, according to the editor’s understanding, Li Auto hopes to further increase sales, and its focus is on the performance of another new car, the Li Li L6. Recently, a blogger allegedly photographed a camouflaged Ideal L6 car in a highway service area. According to the photos taken by the blogger, the camouflaged car suspected to be the Lili L6 is not driving normally, but is parked on a trailer. Compared with the white Weilai SUV next to it, even as the lowest-positioned model in the L series, the Lideal L6 appears to be quite large. It is reported that the Lili L6 is positioned as a medium-sized five-seat SUV. Although these photos don't provide much information about the appearance details

Practical Guide to Regular Expressions in Go: How to Match Hexadecimal Color Codes Practical Guide to Regular Expressions in Go: How to Match Hexadecimal Color Codes Jul 13, 2023 am 10:46 AM

Go Language Regular Expressions Practical Guide: How to Match Hexadecimal Color Codes Introduction: Regular expressions are a powerful and flexible tool for pattern matching and finding strings. In Go language, we can use the built-in regular expression package regexp to implement these operations. This article will introduce how to use regular expressions to match hexadecimal color codes in Go language. Importing the regular expression package First, we need to import the regular expression package regexp of the Go language. You can add the following import statement at the beginning of the code: i

How to write Bloom filter algorithm using C# How to write Bloom filter algorithm using C# Sep 21, 2023 am 10:24 AM

How to use C# to write a Bloom filter algorithm. The Bloom Filter (BloomFilter) is a very space-efficient data structure that can be used to determine whether an element belongs to a set. Its basic idea is to map elements into a bit array through multiple independent hash functions and mark the bits of the corresponding bit array as 1. When judging whether an element belongs to the set, you only need to judge whether the bits of the corresponding bit array are all 1. If any bit is 0, it can be judged that the element is not in the set. Bloom filters feature fast queries and

Write a method to calculate power function in C language Write a method to calculate power function in C language Feb 19, 2024 pm 01:00 PM

How to write exponentiation function in C language Exponentiation (exponentiation) is a commonly used operation in mathematics, which means multiplying a number by itself several times. In C language, we can implement this function by writing a power function. The following will introduce in detail how to write a power function in C language and give specific code examples. Determine the input and output of the function The input of the power function usually contains two parameters: base and exponent, and the output is the calculated result. therefore, we

PHP regular expression in action: matching letters and numbers PHP regular expression in action: matching letters and numbers Jun 22, 2023 pm 04:49 PM

PHP regular expression practice: matching letters and numbers Regular expression is a tool used to match strings, which can easily realize string search, replacement, split and other operations. Regular expressions are also a very useful tool in PHP development. This article will introduce how to use PHP regular expressions to match letters and numbers. Matching a Single Character To match a single character, you can use the character classes in regular expressions. Character classes are represented by square brackets []. The characters in them represent the characters that can be matched. You can use hyphens - to represent ranges.

How to write a dynamic programming algorithm using C# How to write a dynamic programming algorithm using C# Sep 20, 2023 pm 04:03 PM

How to use C# to write dynamic programming algorithm Summary: Dynamic programming is a common algorithm for solving optimization problems and is suitable for a variety of scenarios. This article will introduce how to use C# to write dynamic programming algorithms and provide specific code examples. 1. What is a dynamic programming algorithm? Dynamic Programming (DP) is an algorithmic idea used to solve problems with overlapping subproblems and optimal substructure properties. Dynamic programming decomposes the problem into several sub-problems to solve, and records the solution to each sub-problem.

How to write a simple hotel reservation system using C++? How to write a simple hotel reservation system using C++? Nov 03, 2023 am 11:54 AM

The hotel reservation system is an important information management system that can help hotels achieve more efficient management and better services. If you want to learn how to use C++ to write a simple hotel reservation system, then this article will provide you with a basic framework and detailed implementation steps. Functional Requirements of a Hotel Reservation System Before developing a hotel reservation system, we need to determine the functional requirements for its implementation. A basic hotel reservation system needs to implement at least the following functions: (1) Room information management: including room type, room number, room

How to use C++ to write a simple student course selection system? How to use C++ to write a simple student course selection system? Nov 02, 2023 am 10:54 AM

How to use C++ to write a simple student course selection system? With the continuous development of technology, computer programming has become an essential skill. In the process of learning programming, a simple student course selection system can help us better understand and apply programming languages. In this article, we will introduce how to use C++ to write a simple student course selection system. First, we need to clarify the functions and requirements of this course selection system. A basic student course selection system usually includes the following parts: student information management, course information management, selection

See all articles