SQL from Learning SQL Flashcards

(20 cards)

1
Q

What SQL keyword is used to retrieve data from a table?

A

SELECT

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

Which clause filters rows from the result set based on a condition?

A

WHERE

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

How do you select all columns from a table named ‘products’?

A

SELECT * FROM products;

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

What symbol is used for equality in SQL conditions?

A

=

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

How would you retrieve only the ‘name’ and ‘price’ columns from a table called ‘items’?

A

SELECT name, price FROM items;

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

Which clause is evaluated before SELECT in query execution?

A

FROM

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

What is the default order of results returned by a SQL query?

A

Unordered (unless ORDER BY is used)

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

Which clause is used to sort results in ascending or descending order?

A

ORDER BY

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

How would you sort a query result by the ‘name’ column in descending order?

A

ORDER BY name DESC

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

What is the keyword to eliminate duplicate rows from a SELECT statement?

A

DISTINCT

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

What is the correct order of SQL clauses in a SELECT query?

A

SELECT, FROM, WHERE, ORDER BY

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

Which clause determines which table the data is coming from?

A

FROM

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

True or False: SQL queries are case-sensitive.

A

False

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

Which wildcard character is used in a LIKE clause to match any sequence of characters?

A

%

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

How do you retrieve all products where the name starts with ‘A’?

A

SELECT * FROM products WHERE name LIKE ‘A%’;

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

Which clause is used to filter rows that meet multiple conditions?

A

WHERE with AND/OR

17
Q

How do you write a condition to find rows where ‘price’ is greater than 100?

A

WHERE price > 100

18
Q

What does the BETWEEN operator do in SQL?

A

Selects values within a given range

19
Q

How would you find all products priced between 10 and 50?

A

SELECT * FROM products WHERE price BETWEEN 10 AND 50;

20
Q

Which SQL clause must appear last in a SELECT statement?