MySQL or statement usage example, mysqlor statement example
1. Usage of or syntax in mysql. Note the usage of or in mysql syntax. An error occurred while 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 preceding syntax query is equivalent to the data set queried by two SQL statements.
$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 data sets with act_type = 4 and user_id = 11123 or equal to p. 'Act _ type' = 5 and user_id = 11123 or both conditions, add ().
$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 ;
Summary
The above is all the content about the or statement usage examples in MySQL. I hope it will be helpful to you. If you are interested, you can continue to refer to this site: MySQL statement annotation Method Introduction, SQL and MySQL statement execution sequence analysis, and mysql in statement subquery efficiency optimization tips, if you have any questions, you can leave a message at any time. The editor will reply to you in a timely manner. Thank you for your support for the website!