And condition in MySQL

MySQL AND
In MySQL, the AND condition filters the results obtained through the SELECT, INSERT, UPDATE, and DELETE statements based on multiple conditions.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
WHERE condition_1
AND condition_2
AND condition_3
….
AND condition_n;
WHERE condition_1 AND condition_2 AND condition_3 …. AND condition_n;
WHERE condition_1
AND condition_2
AND condition_3
….
AND condition_n;

Parameters:

condition_1, condition_2… condition_n: They specify the conditions to be strictly followed for selection.

Example: Items table:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
3 Fashion 100
4 Grocery 90
5 Toys 50

 

Query:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SELECT *
FROM items
WHERE id < 4 AND id > 1;
SELECT * FROM items WHERE id < 4 AND id > 1;
SELECT *
FROM items
WHERE id < 4 AND id > 1;

Output:

ID NAME QUANTITY
2 Sports 45
3 Fashion 100