• Learning MySQL By Example
  • Introduction
  • 1. How to Retrieve Data From a Single Table
  • 2. How to Retrieve Data from Multiple Tables
  • 3. Using Functions
  • 4. How to Insert, Update, Delete Data in Tables
  • 5. Summary Queries and Aggregate Functions
  • 6. Working With Subqueries
  • 7. SQL Views
  • 8. SQL Indexes
  • Glossary
  • Index
  • Download
  • Translations
  • 1.7

    IS NULL, BETWEEN, IN Operators


    • Null values indicate an unknown or non-existent value and is different from an empty string (‘ ‘).
    • To test for a null value you use the IS NULL clause
    • The test for a value use IS NOT NULL clause


    SELECT name, IndepYear
    FROM country
    WHERE IndepYear IS NULL;



    BETWEEN Operators

    • The BETWEEN operator is similar to >= and <=.
    • BETWEEN includes everything between the two values indicated.
    • BETWEEN works with both text and number.


    USE world;
    SELECT name, IndepYear
    FROM country
    WHERE name BETWEEN "Aruba" and "Bahamas";



    The IN Keyword

    • The IN clause tests whether an expression is equal to a value or values in a list of expressions.
    • The order of the items in the list does not matter.
    • You can use the NOT operator to test for items not in the list.
    • The IN clause may be used with a subquery.


    USE world;
    SELECT name
    FROM country
    WHERE name IN ('Aruba', 'Barbados', 'Cuba', 'Bahamas')
    ORDER BY population ASC;



    This content is provided to you freely by EdTech Books.

    Access it online or download it at https://edtechbooks.org/learning_mysql/is_null_between_in_o.