Press "Enter" to skip to content

mysqlandoperator

MySQL AND operator

One off Mysql Logical operator is AND .The purpose of this operator is to combine two or more Boolean expressions and returns true only if both expressions evaluate to true.If one off condition become false then AND opertor returns false

To filter the result in WHERE clause of the SELECT, UPDATE, DELETE the AND opertor is used.The AND opertor also used with join or letf join clause.

SYNTAX


SELECT DISTINCT
columns
FROM
table_name
WHERE
column AND column

Table structure Used for Example explanation

+—————-+————+
| Field | Type |
+—————-+————+
| Code | char(3) |
| Name | char(52) |
| Continent | char(40) |
| Region | char(26) |
| SurfaceArea | float(10,2)|
| IndepYear | smallint(6)|
| Population | int(11) |
| LifeExpectancy | float(3,1) |
| GNP | float(10,2)|
| GNPOld | float(10,2)|
| LocalName | char(45) |
| GovernmentForm | char(45) |
| HeadOfState | char(60) |
| Capital | int(11) |
| Code2 | char(2) |
+—————-+————+

Example for MySQL AND operator

SELECT Name, Population FROM Country WHERE Population > 100000000 AND (Continent = ‘Asia’ );

Output of Above Example

+————+————+
| Name | Population |
+————+————+
| Bangladesh | 129155000 |
| Indonesia | 212107000 |
| India | 1013662000 |
| Japan | 126714000 |
| China | 1277558000 |
| Pakistan | 156483000 |