Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use or statement in MySQL

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following mainly brings you the use of or sentences in MySQL. I hope these words can bring you practical use, which is also the main purpose of this article when I edit the use of or sentences in MySQL. All right, don't talk too much nonsense, let's just read the following.

$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, and the above syntax query is equivalent to: two sets of data queried by sql.

$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

two。 To query the data set act_type = 4 and user_id = 11123 or equal to p.`act _ type` = 5 and user_id = 11123, the conditions on both sides of the or 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

For the above about the use of or statements in MySQL, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report