0% found this document useful (0 votes)
10 views3 pages

Notes 1

SQL, or Structured Query Language, is used to interact with data in a database, performing major tasks known as CRUD: Create, Read, Update, and Delete. The document outlines various SQL queries for selecting and filtering data from a 'movies' database, including examples of constraints and sorting results. It also includes links to lessons for further learning on SQL query techniques.

Uploaded by

Titiksha Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Notes 1

SQL, or Structured Query Language, is used to interact with data in a database, performing major tasks known as CRUD: Create, Read, Update, and Delete. The document outlines various SQL queries for selecting and filtering data from a 'movies' database, including examples of constraints and sorting results. It also includes links to lessons for further learning on SQL query techniques.

Uploaded by

Titiksha Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL - Structured Query Language

Why do we use SQL ?

Data also has home - Database


To interact with the data in the database, we need a language - SQL

4 major tasks that we can do with data - CRUD Tasks

C - Creating new data in the database


R - Reading the data from the database
U - Updating the data in the database
D - Deleting the data

Lesson 1

[Link]

select title from movies ;

select director from movies ;

select title, director from movies ;

select title, year from movies ;

select * from movies ;

Lesson 2

[Link]

SELECT * FROM movies


where id = 6 ;

SELECT * FROM movies


where year between 2000 and 2010 ;

SELECT * FROM movies


where year not between 2000 and 2010 ;

SELECT * FROM movies


limit 5 ;
Lesson 3

[Link]

SELECT * FROM movies


where title like "Toy Story%" ;

SELECT * FROM movies


where director = "John Lasseter" ;

SELECT * FROM movies


where director is not "John Lasseter" ;

SELECT * FROM movies


where title like "WALL%" ;

Lesson 4

[Link]

SELECT distinct director FROM movies


order by director asc ;

SELECT * from movies


order by year desc
limit 4 ;

SELECT * from movies


order by title asc
limit 5 ;

SELECT * from movies


order by title asc
limit 5 offset 5 ;

Lesson 5

[Link]

SELECT * FROM north_american_cities


where country = "Canada" ;
SELECT * FROM north_american_cities
where country = "Mexico"
order by population desc
limit 2 ;

SELECT * FROM north_american_cities


where country = "United States"
order by population desc
limit 2 offset 2 ;

You might also like