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 ;