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 and in mysql

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to use and in mysql", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use and in mysql" this article.

In mysql, and is often used in where substatements to combine two or more conditions and return true only if multiple conditions evaluate to true. The syntax is "WHERE condition 1 AND condition 2".

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

The AND operator is a logical operator that combines two or more Boolean expressions and returns true only if two expressions evaluate to true. If one of the two expressions evaluates to false, the AND operator returns false.

WHERE boolean_expression_1 AND boolean_expression_2SQL

The following shows what happens when the AND operator combines true,false and null.

The AND operator is commonly used in the WHERE clause of a SELECT,UPDATE,DELETE statement to form a Boolean expression. The AND operator is also used for join conditions of INNER JOIN or LEFT JOIN clauses.

When an expression with an AND operator is evaluated, MySQL evaluates the rest of the expression until the result can be determined. This feature is called short-circuit evaluation. See the following example.

SELECT 1 = 0 AND 1 / 0; Shell

When you execute the above query, you get the following results-

Mysql > SELECT 1 = 0 AND 1 / 0; +-+ | 1 = 0 AND 1 / 0 | +-+ | 0 | +-+ 1 row in setShell

Note that in MySQL, 0 is considered false and non-zero is considered true.

MySQL only evaluates the first part of the expression 1 = 0 AND 1 AND 0, 1 = 0, because the expression 1 = 0 returns false, so MySQL concludes that the result of the entire expression is false. MySQL does not evaluate the rest of the expression, that is, it does not evaluate 1max 0; if it evaluates 1max 0, it issues an error message because it is divided by zero error.

The above is all the contents of the article "how to use and in mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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