当前位置:网站首页>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 .
边栏推荐
- SVD singular value decomposition derivation and application and signal recovery
- CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
- 2600 pages in total! Another divine interview manual is available~
- Pytoch learning notes -- Summary of common functions 2
- Binary complement
- Hdu3873 shortest path with dependency (topological sorting)
- Why is preparestatement better and safer?
- LeetCode - 677 键值映射(设计)*
- Data system partition design - Request Routing
- Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
猜你喜欢

Reasons for data format conversion when matlab reads the displayed image

活动回顾|7月6日安远AI x 机器之心系列讲座第2期|麻省理工教授Max Tegmark分享「人类与AI的共生演化 」

Leetcode - 303 area and retrieval - array immutable (design prefix and array)

MATLAB optimization tool manopt installation

MySQL - user and permission control

Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output

Leetcode - 225 implements stack with queue

Pytorch学习笔记-Advanced_CNN(Using Inception_Module)实现Mnist数据集分类-(注释及结果)

Leetcode - 232 realize queue with stack (design double stack to realize queue)

SVD singular value decomposition derivation and application and signal recovery
随机推荐
Circulaindicator component, which makes the indicator style more diversified
PAT甲级1151 LCA in a Binary Tree (30 分)
MySQL—常用SQL语句整理总结
2600 pages in total! Another divine interview manual is available~
CVPR 2022 | in depth study of batch normalized estimation offset in network
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
Componentization and modularization
【莎士比亚:保持做人的乐趣】
电阻电路的等效变化(Ⅱ)
Zhaoqi Kechuang high-level innovation and Entrepreneurship Talent Service Platform at home and abroad, mass entrepreneurship and innovation achievement transformation platform
通用测试用例写作规范
BSC smart chain contract mode system development details
Pytoch learning notes -- Summary of common functions of pytoch 1
Pytoch learning notes advanced_ CNN (using perception_module) implements MNIST dataset classification - (comments and results)
Binary complement
"Digital security" alert NFT's seven Scams
P4552 differential
Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel
Leetcode - 641 design cycle double ended queue (Design)*
如何解决跨域问题