Thursday, May 23, 2019

SQL(5)---Queries with constraints EXAMPLE

Queries with constraints
EXAMPLE:

  • Find the movie with a row id of 6

SELECT id, title FROM movies 
WHERE id = 6;

The table will look like:


  • Find the movies released in the year between 2000 and 2010


  • SELECT title, year FROM movies
    WHERE year BETWEEN 2000 AND 2010;

    The table will look like:



  • Find the movies not released in the years between 2000 and 2010

  • SELECT title, year FROM movies
    WHERE year < 2000 OR year > 2010;

    The table will look like:

  • Find the first 5 Pixar movies and their release year



  • SELECT title, year FROM movies 
    WHERE year <= 2003;



    The table will look like:

    NOTES: This was the example that I looked at to help my understanding of the lesson. 
    What I'll be doing tomorrow?
    Queries with constraints

    No comments:

    Post a Comment