sql-select Flashcards

1
Q

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

A

SQL is used for inserting, updating, retrieving, and deleting data in a database, while JavaScript is used to add interactivity and dynamic effects to websites.

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

To retrieve specific columns from a database table, you can use a SQL SELECT statement with the desired column names in the SELECT clause. For example:

SELECT column1, column2, column3
FROM 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

you can use the WHERE clause in a SQL SELECT statement.

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 helps reduce the likelihood of syntax and logical errors, as well as making it easier to catch such errors when they do occur.

Overall, formatting SQL code can help increase productivity, reduce errors and improve the maintainability of your code.

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

= (equal to)
< (less than)
> (greater than)
<> or != (not equal to)

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

LIMIT

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

a wildcard character * in the SELECT clause of a SQL SELECT statement.

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

“ORDER BY”

SELECT column1, column2, …
FROM table_name
ORDER BY column1 DESC, column2 ASC;

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