当前位置:网站首页>MySQL tutorial 71-where conditional query data
MySQL tutorial 71-where conditional query data
2022-07-25 15:57:00 【51CTO】
stay MySQL in , If you need to query data conditionally from the data table , have access to WHERE Keyword to specify query criteria .
Use WHERE The syntax format of the keyword is as follows :
Query criteria can be :
- Query conditions with comparison operators and logical operators
- belt BETWEEN AND Keyword query conditions
- belt IS NULL Keyword query conditions
- belt IN Keyword query conditions
- belt LIKE Keyword query conditions
Single condition query statement
A single condition refers to WHERE There is only one query condition after the keyword .
example 1
stay tb_students_info The height queried in the data table is 170cm Student name of ,SQL Statement and run results are as follows .
You can see , Recorded in the query results height The value of the field is equal to 170. If you query according to the specified conditions , There are no records matching the query conditions in the data table , The system will prompt “Empty set(0.00sec)”.
example 2
stay tb_students_info The query age in the data table is less than 22 Student name of ,SQL Statement and run results are as follows .
You can see , All records in the query results age The values of the fields are all less than 22 year , And greater than or equal to 22 The record of years old was not returned .
Multi conditional query statement
stay WHERE There can be multiple query conditions after keywords , This can make the query results more accurate . Use logical operators when multiple query conditions AND(&&)、OR(||) or XOR separate .
- AND: When all query conditions are met , Will be found out .
- OR: When the record meets any query condition , Will be found out .
- XOR: Record that one of the conditions is met , And do not meet another condition , Will be found out .
example 3
stay tb_students_info Query in table age Greater than 21, also height Greater than or equal to 175 Student information ,SQL Statement and run results are as follows .
You can see , All records in the query results age All fields are greater than 21 And height Fields are greater than or equal to 175.
example 4
stay tb_students_info Query in table age Greater than 21, perhaps height Greater than or equal to 175 Student information ,SQL Statement and run results are as follows .
You can see , All records in the query results age All fields are greater than 21 perhaps height Fields are greater than or equal to 175.
example 5
stay tb_students_info Query in table age Greater than 21, also height Less than 175 Student information and age Less than 21, also height Greater than or equal to 175 Student information ,SQL Statement and run results are as follows .
You can see , All records in the query results age All fields are greater than 21 And height Fields are less than 175.tb_students_info Not in the data table age The field is less than 21 And height Field is greater than or equal to 175 The record of .
OR、AND and XOR Can be used together , But pay attention to the priority of operators when using
The more query conditions , The fewer records will be found . because , The more conditions you set , There are more restrictions on query statements , Fewer records can meet all the conditions . In order to make the queried records exactly what you want , Can be in WHERE Statement to set the query conditions more specifically .
边栏推荐
- User defined annotation verification API parameter phone number
- ZOJ - 4114 flipping game DP, reasonable state representation
- LeetCode - 303 区域和检索 - 数组不可变 (设计 前缀和数组)
- LeetCode - 641 设计循环双端队列(设计)*
- Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results
- Pytorch学习笔记-Advanced_CNN(Using Inception_Module)实现Mnist数据集分类-(注释及结果)
- Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
- 不愧是阿里内部“千亿级并发系统架构设计笔记”面面俱到,太全了
- The difference between mouseover and mouseenter
- Pat grade a 1153 decode registration card of PAT (25 points)
猜你喜欢

Redis分布式锁,没它真不行

HDD Hangzhou station · harmonyos technical experts share the features of Huawei deveco studio

LeetCode - 641 设计循环双端队列(设计)*

Idea - click the file code to automatically synchronize with the directory

Ml image depth learning and convolution neural network

Leetcode - 677 key value mapping (Design)*

MATLAB optimization tool manopt installation

Matlab simulation of BPSK modulation system (1)

Geogle colab notes 1-- run the.Py file on the cloud hard disk of Geogle

Gary marcus: learning a language is more difficult than you think
随机推荐
Qtime definition (manual waste utilization is simple and beautiful)
我想问下变量配置功能是只能在SQL模式下使用吗
ML - Speech - traditional speech model
微信小程序
Zhaoqi Kechuang high-level innovation and Entrepreneurship Talent Service Platform at home and abroad, mass entrepreneurship and innovation achievement transformation platform
2021 Jiangsu race a Array line segment tree, maintain value range, Euler power reduction
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
Matlab simulation of BPSK modulation system (1)
Leetcode - 225 implements stack with queue
Why is preparestatement better and safer?
2021 Shanghai match-b-ranked DP
Data system partition design - Request Routing
2021hncpc-e-difference, thinking
MySQL - user and permission control
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
Cf566a greed + dictionary tree
「数字安全」警惕 NFT的七大骗局
Reasons for data format conversion when matlab reads the displayed image
Pytoch learning notes -- Summary of common functions 3
Redis分布式锁,没它真不行