MySQL WHERE Clause with AND, OR, IN, NOT IN

MySQL WHERE clause multiple values with update, equal operator, AND operator, OR operator, BETWEEN operator, where in array, where in list, LIKE operator, the IN operator, the IS NULL operator and comparison operators with multiple conditions multiple subquery in mysql.

MySQL WHERE clause

 SELECT 
    select_list
FROM
    table_name
WHERE
    search_condition;

MySQL WHERE clause with equal operator

SELECT 
    membersirname, 
    membername, 
    occupation_name
FROM
    members
WHERE
    occupation_name = 'Devloper Rep';

MySQL WHERE clause with AND operator

SELECT 
    membersirname, 
    membername, 
    occupation_name,
    branch_code
FROM
    members
WHERE
    occupation_name = 'Devloper Rep' AND 
    branch_code = 1;

MySQL WHERE clause with OR operator

SELECT 
    member_sir_name, 
    member_name, 
    Ocupattion_name, 
    branch_code
FROM
    members
WHERE
    occupation_name = 'Devloper Rep' OR 
    branch_code = 1
ORDER BY 
    branch_code , 
    Ocupattion_name;

WHERE with BETWEEN operator

SELECT 
    member_name, 
    member_sir_name, 
    branch_code
FROM
    members
WHERE
    branch_code BETWEEN 1 AND 3
ORDER BY branch_code;
[php]

<h2>WHERE with the LIKE operator</h2>
[php]
SELECT 
    member_name, 
    member_sir_name
FROM
    members
WHERE
    member_sir_name LIKE '%son'
ORDER BY member_name;

WHERE clause with the IN operator

SELECT 
    member_name, 
    member_sir_name, 
    branch_code
FROM
    members
WHERE
    branch_code IN (1 , 2, 3)
ORDER BY 
    branch_code;

WHERE clause with the IS NULL operator

SELECT 
    member_sir_name, 
    member_name, 
    reportsTo
FROM
    members
WHERE
    reportsTo IS NULL;

MySQL WHERE clause with comparison operators

SELECT 
    membersirname, 
    membername, 
    occupation_name
FROM
    members
WHERE
    occupation_name <> 'Devloper Rep';

The following query finds members whose branch code is greater than 5:

SELECT 
    membersirname, 
    membername, 
    branch_code
FROM
    members
WHERE 
    branchcode > 5;

The following query returns members with branch code less than or equal 4 (<=4):
SELECT 
    membersirname, 
    membername, 
    branch_code
FROM
    members
WHERE 
    branchcode <= 4;

I hope you get an idea about MySQL WHERE.
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.

Read Also:  Laravel get last Eloquent print query

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 5.5 Resolve errors The page has expired due to inactivity
  2. Read Also:  How to upgrade php 5.6 to php 7 in XAMPP on Windows?
  3. Read Also:  how to upload image in ckeditor in Laravel?
  4. Read Also:  Mongodb Insert Update Delete – CRUD Operation using PHP & Mongodb
  5. Read Also:  Laravel 6 Eloquent Query Retrieving Single Models
  6. Read Also:  laravel Add cascade on delete (ON DELETE CASCADE)
  7. Read Also:  Simple PHP jQuery Ajax Insert Update Delete using MySQLi
  8. Read Also:  PHP Multidimensional Array Remove Duplicates
  9. Read Also:  PHP Pagination demo – Pagination in PHP with example script
  10. Read Also:  Codeigniter delete query from Database
CLOSEX