The previous article introduced the MySql multi-condition query statement with the And keyword. The following article introduces the MySql multi-condition query statement with the OR keyword. Friends who are interested can learn together. MySQL's multi-condition query with the OR keyword is different from the AND keyword. With the OR keyword, as long as the record meets any one of the conditions, it will be queried. SELECT * | {field name 1, field name 2, ...} FROM table name WHERE conditional expression 1 OR conditional expression 2 […… OR conditional expression n]; Query the names of students in the student table whose id field value is less than 15 or whose gender field value is nv It can be seen that among the 5 records returned, 3 records have an id field value less than 15, or a gender field value of nv Query the student table for records where the name field value starts with the character "h" or the grade field value is 100 It can be seen that the records that meet the conditions are queried When OR and AND keywords are used together The OR keyword and the AND keyword can be used together. Note that AND has a higher priority than OR. Therefore, when the two are used together, the conditional expressions on both sides of AND should be calculated first, and then the conditional expressions on both sides of OR Query the names of students in the student table whose gender field value is nv, or whose gender field value is na, and whose grade field value is 100 It can be seen If the priority of AND is the same as or lower than that of OR, the AND operation will be executed last and the query result will return one record. Here, three records are returned, indicating that the AND operation is executed first and the OR operation is executed later, that is, AND has a higher priority than OR. The above is the MySql multi-condition query statement with OR keyword introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Basic usage tutorial of IPTABLES firewall in LINUX
>>: React hooks introductory tutorial
As shown above, the navigation is fixed at the to...
This article example shares the specific code of ...
MySQL string concatenation, interception, replace...
Table of contents Error message Cause Error demon...
2.1 Semanticization makes your web pages better u...
Table of contents Query cache optimization Overvi...
Preface The Windows system that can be activated ...
Table of contents Preface 1. Define label style 2...
MySQL master-slave setup MySQL master-slave repli...
CSS Layout - position Property The position attri...
CSS3 -- Adding shadows (using box shadows) CSS3 -...
This article introduces how to build a high-avail...
CSS3 implements a flippable hover effect. The spe...
How to solve the problem of being unable to acces...
The specific method is as follows: CSS Code Copy ...