Skip to content
CodeItRaw
SQL: Select and Filter

Lesson 3/3

When you know part of a text and not all of it, you use LIKE. In the pattern % means "anything, nothing included" and _ exactly one character. 'M%' is those starting with M, '%son' those ending in "son", '%ar%' those with "ar" anywhere inside.

SELECT title
FROM books
WHERE title LIKE 'The %'
AND translator IS NULL;
Books that start with "The " and have no translator. A missing value (NULL) means "unknown" and cannot be compared with =; it has a question of its own: IS NULL, and the opposite, IS NOT NULL.

NULL is not zero and not an empty text. If an employee's city is NULL the city is unknown; if it is '' the city is an empty text. They are different rows and are found with different conditions.

Tasks

Tasks open in order. Solve them all and the next lesson opens.

This lesson's tasks open when the lessons before it are finished. You can read the explanation now.Go to the current lesson

  1. 01

    Starts with a letter

    SQL query

  2. 02

    Missing values

    SQL query

If you would rather not wait for the order, every problem is open without locks: Problem list