SQL or syntax, sqlor
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 ;