mysql multiple where clauses for beginners with Best 5 examples – Multiple WHERE with AND & OR Operators

mysql multiple where clauses : here we can learn to Multiple WHERE with AND & OR Operators, Joining Tables, WHERE clause combined with – NOT IN Keyword, WHERE clause combined with – IN Keyword and many more. also WHERE Clause in MySQL is a best keyword used to some specific the match criteria of data or rows.

mysql multiple where clauses

Example 1: MySQL Multiple Where Clause

mysql multiple where clauses
mysql multiple where clauses

Example – With Single condition

SELECT *
FROM members
WHERE last_name = 'Krisnhukanji';

AND Operator

SELECT item_id, item_name, item_price
FROM items
WHERE item_id <= 6 AND item_price <= 15;

SELECT *
FROM members
WHERE state = 'Gujrat'
AND member_id > 1250;

OR Operator

SELECT item_name, item_price
FROM items
WHERE item_id <= 6 OR item_price <= 15;

Free Live Chat for Any Issue

SELECT member_id
FROM members
WHERE member_name = 'Nikunj'
OR member_name = 'Ramchandra';

Using AND and OR in Correct Order

SELECT item_name, item_price
FROM items
WHERE member_id = 1054 OR member_id = 1024 AND item_price >= 45;

SELECT *
FROM members
WHERE (state = 'Gujrat' AND member_name = 'Pavan')
OR (member_id > 5000);

Example – Joining Tables

SELECT members.member_name, details.detail_id
FROM members, details
WHERE members.member_id = details.member_id
AND members.state = 'Gujrat';

group related operators

SELECT item_name, item_price
FROM items
WHERE (member_id = 1002 OR member_id = 1003) AND item_price >= 15;

= Equal To

SELECT * FROM `fruits` WHERE `type` = 'small';

< > Not Equal To

SELECT * FROM `fruits` WHERE `category_id`<> 1;

> Greater than

SELECT * FROM `fruits` WHERE `price_per_kg` > 2000;

WHERE clause combined with – NOT IN Keyword

SELECT * FROM `fruits` WHERE `fruits_qty` NOT IN (20,41,52);

WHERE clause combined with – IN Keyword

SELECT * FROM `fruits` WHERE `fruits_qty` IN (8,45,10,11);

Where Clause Command Prompt Example

USE world;
SELECT fCode, fName,
       location, type,
       SurfaceArea, price,
       fruitsqty, fLocalName        
FROM fruits
WHERE location = 'Rajkot' AND price > 425;

Using MySQL WHERE with BETWEEN operator example

SELECT 
    fCode, 
    fName, 
    price
FROM
    fruits
WHERE
    price BETWEEN 10 AND 50
ORDER BY price;

I hope you get an idea about mysql multiple where clauses (Advanced MySQL Data Filtering – AND, OR, NOT and IN
)
.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.

Rate this post