1. The use of or syntax in MySQL, and the points to note when using or in MySQL syntax. The project encountered a pitfall, and there was an error in querying the reward data! ! ! $sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE p.`act_type` = 4 or p.`act_type` = 5 AND p.`user_id` = ' .$user_id ; The or syntax in sql is generally used for queries with multiple conditions. The above syntax query is equivalent to: the data sets obtained by two sql queries. $sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE p.`act_type` = 4; $sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE p.`act_type` = 5 AND p.`user_id` = ' .$user_id; 2. To query the data set where act_type = 4 and user_id = 11123 or p.`act_type` = 5 and user_id = 11123, you must add () to the conditions on both sides of the or. $sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE (p.`act_type` = 4 or p.`act_type` = 5) AND p.`user_id` = ' .$user_id ; Summarize The above is all the content of this article about the usage examples of or statements in MySQL. I hope it will be helpful to you. Interested friends can continue to refer to this site: Introduction to MySQL statement comment method, Analysis of SQL and MySQL statement execution order, Examples of optimization techniques for slow subquery efficiency of MySQL in statement, etc. If you have any questions, you can leave a message at any time and the editor will reply to you in time. Thank you friends for your support of 123WORDPRESS.COM! You may also be interested in:
|
<<: Installing Win10 system on VMware workstation 14 pro
>>: Vue implements an example of pulling down and scrolling to load data
Let's first look at some simple data: Accordin...
This question is a discussion among netizens in a...
<br />Previously, we learned how to set cell...
Copy code The code is as follows: <html> &l...
Table of contents 1. Download 2. Installation 3. ...
Table of contents Overview 1. Simple Example 1. U...
MyISAM storage engine MyISAM is based on the ISAM...
Table of contents 1. Demo Project 1.1 Interface P...
Yesterday I wanted to use a:visited to change the...
This article example shares the specific code for...
This article mainly introduces the sql script fun...
Download tutorial of mysql-connector-java.jar pac...
This article shares the specific code for JavaScr...
Execute Command docker run -d --name consul -p 85...
I recently upgraded MySQL to 5.7, and WordPress r...