1. The use of or syntax in mysql, points to note when using or in mysql syntax.
$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: two sql The queried data collection.
<span style="color: #000000"> $sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE p.`act_type` = 4;<br/><span style="color: #000000">$sql = 'SELECT * FROM `vvt_spread_doubleegg_exchange_award` AS p WHERE <span style="color: #000000">p.`act_type` = 5 AND p.`user_id` = ' .$user_id</span>;</span></span>
2. If you want to query the data set of act_type = 4 and user_id = 11123 or equal to p.`act_type` = 5 and user_id = 11123 or both sides The condition must be added ().
$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 above is the detailed content of Introduction to or syntax in sql. For more information, please follow other related articles on the PHP Chinese website!