Filtering: AND, IN, LIKE and NULL
Real questions have several conditions. This is also where you'll meet NULL, which trips up nearly everyone once.
● A real database, running in your browser. Nothing you type leaves this page.
Exercise 1 of 7
Two conditions
AND needs both to be true, and OR needs either. Use brackets when you mix them, as AND goes first.
Your task
Show the first_name of employees in department 1 earning 6000 or more.
Tables and columns
or Ctrl+Enter
What you'll practice
- Two conditions.
ANDneeds both to be true, andORneeds either. Use brackets when you mix them, asANDgoes first. - One of several values.
INis a shorter way to write manyORs on one column. - Part of a text.
LIKEmatches patterns, where%means any text. In PostgreSQL, it's case-sensitive, andILIKEignores case.LIKEmatches patterns, where%means any text. In SQLite, it ignores case for plain letters by default, unlike PostgreSQL. - Missing values.
NULLmeans "no value", and `= NULL` is never true, not even forNULL. UseIS NULL. - Projects still open. The same goes here: an open project has no end date.
- A range of dates.
BETWEENincludes both ends. Write dates asYYYY-MM-DD. - True or false. A boolean column can be compared with
trueorfalse. SQLite stores booleans as1and0, and understandstrueandfalseas those numbers.