Ga naar inhoud

Header

Filtering with WHERE - Assignments

1. Retrieve data of actors with a specific first name

Complete the following query to obtain data from the actors table, where the first name (column first_name) is equal to 'Jennifer'.

  • Use the WHERE statement.
SELECT
  *
FROM
  actors
...
  ... = '...';




2. Retrieve data of actors with a specific beginning of the first name

Complete the following query to obtain data from the actors table, where the first name (column first_name) begins with 'John'.

  • Use the WHERE statement.
  • Use the LIKE statement.
  • Use the % sign.
...
  *
...
  actors
...
  ... ... '...';




3. Retrieve data of actors with the last name from a list

Complete the following query to obtain data from the actors table, where the last name (column last_name) appears in the list: 'Anderson', 'Douglas', 'Williams'.

  • Use the WHERE statement.
  • Use the IN() operator.
...
  *
...
  ...
...
  ... ...(...);




4. Retrieve data of actors with a specific number of films

Complete the following query to obtain data from the actors table, where the number of films (column film_count) is equal to 3.

  • Use the WHERE statement.
...
  *
...
  ...
...
  ...;




5. Retrieve data of actors with the number of films greater than or equal to a value

Complete the following query to obtain data from the actors table, where the number of films (column film_count) is greater than or equal to 3.

  • Use the WHERE statement.
  • Use the >= operator.
...
  *
...
  ...
...
  ...;




6. Retrieve data of actors with the number of films in a range

Complete the following query to obtain data from the actors table, where the number of films (column film_count) is at least 2 and at most 4.

  • Use the WHERE statement.
  • Use the BETWEEN and AND operators.
...
  *
...
  ...
...
  ...;




7. Retrieve data of actors with a specific gender and a specific number of films

Complete the following query to obtain data from the actors table, where:

  • The gender (column gender) is female ('F').
  • And the number of films (column film_count) is at least 2.


  • Use the WHERE statement.
  • Use the AND operator.
...
  *
...
  ...
...
  ...;




8. (Extra) Retrieve data of actors with requirements for the first name

Complete the following query to obtain data from the actors table, where:

  • The first name (column first_name) must begin with 'John'.
  • The length of the first name must be less than or equal to 9 characters.


  • Use the WHERE statement.
  • Use the LIKE operator.
  • Use the LENGTH() function.
...




9. (Extra) Retrieve data of actors with requirements for the first and last name (1)

Complete the following query to obtain data from the actors table, where:

  • The first name (column first_name) must begin with the letter 'j'.
    • It should not matter if it is a lowercase or uppercase letter.
  • The second letter of the last name (column last_name) must be equal to the letter a.
    • It should not matter if it is a lowercase or uppercase letter.
  • The length of the last name must be greater than or equal to 10 characters.


  • Use the WHERE statement.
  • Use the LIKE operator.
  • Use the LENGTH() function.
...




10. (Extra) Retrieve data of actors with requirements for the first and last name (2)

Complete the following query to obtain data from the actors table, where:

  • The first name (column first_name) must begin with the letters 'je'.
    • It should not matter if it is a lowercase or uppercase letter.
  • The last name (column last_name) must not appear in the list 'douglas', 'morrison'.
    • It should not matter if it is a lowercase or uppercase letter.


...