AND Operator MySQL Essential Training

AND Operator MySQL Essential Training

MYSQL

AND Operator MySQL Essential Training




In this lesson AND Operator MySQL Essential Training we are gonna learn in deep about one of the important logical operator AND in MySQL.
The AND operator is a logical operator that combines two or more Boolean expressions and returns true only if both expressions evaluate to true. The AND operator returns false if one of the two expressions evaluate to false. Here it plays important role when we wants to execute a query with two combined conditions.

The following table gives you a graphical result about how the combinations of true, false and null.
AND Operator MySQL Essential Training
The AND operator is some times or often used in SELECT, WHERE, UPDATE and DELETE conditions to make the filter in more effective ways. It also used in the inner join and left join clauses.
When evaluating an expression that has an AND operator, MySQL evaluates the remaining parts of the expression until it can determine the result. This is called short-circuit evaluation.
Consider the following example for better understanding:

AND Operator MySQL Essential Training




Consider that in MySQL 0 is considered as NULL, and non-zero is true.
In AND Operator MySQL Essential Training lesson the above example shows the result as 0. And it doesn’t shows the result for the remaining part. When MySQL finds the first part is false then it decides the entire query as false. In case if we give the first equation as second and the second as first then it shows some error message, because of the divide by zero.
MySQL AND Operator Examples
Lets take the emp_details table for the real time example which is used in our previous lessons. For using that we have to do the basics to access the table like use database_name and etc.
The following statement selects employees who addressed ‘NewYork’ and designation as ‘Artist’. The MySQL statement to get this result is:

AND Operator MySQL Essential Training
In this AND Operator MySQL Essential Training lesson the next example is how to implement the AND condition more than one time on a statement. With AND operator, we can combine more than two boolean expressions. For example the below given query is get the rows which are designation as ‘Artist’ and addressed at ‘NewYork’ and Country as ‘USA’.

The following is the result for the above query.
AND Operator MySQL Essential Training




These are the basic functions of the AND Operator MySQL Essential Training. We hope this lesson will taught you some knowledge about the AND operator. The next lesson will be OR Operator Functions.

Leave a Reply