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
This article example shares the specific code of ...
Considering that many people now use smartphones, ...
Sometimes we need to remotely run programs on the...
If someone asked you whether running EXPLAIN on a...
Table of contents Install mysql Configuring envir...
Web design is both a science and an art. Web desi...
Problem Description There is a type of query call...
<br />How can I remove the scroll bar on the...
Preface: Because many business tables use design ...
Related system calls for file operations create i...
What are slots? The slot directive is v-slot, whi...
html: In fact, it is to arrange several solid cir...
The function has been implemented a long time ago...
1. Overview Users expect the web applications the...
Table of contents 1. What is a calculated propert...