sql Flashcards
create a table called flights
create table flights (
id integer primary key autoincrement,
origin text not null,
destination text not null,
duration integer not null
);
insert values into flights
insert into flights (origin, destination, duration) values (“NY”, “London”, 400);
select specific columns from flights
select column1, column2 FROM flights
select specific rows from flights
select * from flights where id = 3
(can be any value of any column, like “New York”)
select specific rows from flights with conditions
select * from flights where duration > 500 AND destination = “Paris”;
select multiple rows based on conditions
select * from flights where origin IN (“New York” , “Paris”);
select rows similar to value
select * from flights WHERE origin LIKE “%a%”;
(all things that have an “a” in them)
update values in DB
UPDATE flights SET duration = 500
WHERE origin = “New York”
AND destination = “London”;
delete data
DELETE FROM flights WHERE destination = “Tokyo”;
other clauses
LIMIT
ORDER BY
GROUP BY
HAVING