sql Flashcards

1
Q

create a table called flights

A

create table flights (
id integer primary key autoincrement,
origin text not null,
destination text not null,
duration integer not null
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

insert values into flights

A

insert into flights (origin, destination, duration) values (“NY”, “London”, 400);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

select specific columns from flights

A

select column1, column2 FROM flights

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

select specific rows from flights

A

select * from flights where id = 3
(can be any value of any column, like “New York”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

select specific rows from flights with conditions

A

select * from flights where duration > 500 AND destination = “Paris”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

select multiple rows based on conditions

A

select * from flights where origin IN (“New York” , “Paris”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

select rows similar to value

A

select * from flights WHERE origin LIKE “%a%”;
(all things that have an “a” in them)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

update values in DB

A

UPDATE flights SET duration = 500
WHERE origin = “New York”
AND destination = “London”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

delete data

A

DELETE FROM flights WHERE destination = “Tokyo”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

other clauses

A

LIMIT
ORDER BY
GROUP BY
HAVING

How well did you know this?
1
Not at all
2
3
4
5
Perfectly