sql-select Flashcards

1
Q

What is SQL and how is it different from languages like JavaScript?

A

It is a declarative programming language which means you ask the language to do something and it finds a way to return a result while JS is an imperative language which means you tell the language what to do and how to do it.

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

How do you retrieve specific columns from a database table?

A

Use the SELECT keyword followed by names of columns in double quotes, separated by commas. Then use the FROM keyword followed by the table name.

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

How do you filter rows based on some specific criteria?

A

The WHERE keyword filters the amount of rows based on a comparison of a column value to a filter value that you decide

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

What are the benefits of formatting your SQL?

A

Formatting provides a consistent style which increases readability.

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

What are four comparison operators that can be used in a where clause?

A

”=”, “<”, “>”, “!=”

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

How do you limit the number of rows returned in a result set?

A

Use the LIMIT keyword followed by an integer representing the amount of rows to return

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

How do you retrieve all columns from a database table?

A

Use the SELECT keyword followed by the * followed by the keyword FROM followed by the table name

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

How do you control the sort order of a result set?

A

Use the keyword ORDER BY followed by a column name followed by keyword DESC if you want the data to be in descending order instead of ascending order.

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