W3. SQL Where Flashcards

1
Q

Q: What is the purpose of the SQL WHERE clause?

A

A: To filter records and extract only those that meet a specified condition.

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

Q: Write a SQL query to select all customers from Mexico.

A
SELECT * FROM Customers 
WHERE Country='Mexico';
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the general syntax for using the WHERE clause in SQL?

A

SELECT column1, column2, …
FROM table_name
WHERE condition;

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

Q: Can the WHERE clause be used in statements other than SELECT?

A

A: Yes, it can also be used in UPDATE, DELETE, and other statements.

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

Q: How should text and numeric values be formatted in the WHERE clause?

A

A: Text values should be enclosed in single (or double) quotes, but numeric values should not be enclosed in quotes.

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

Q: Write a query to select a customer with CustomerID equal to 1.

A
SELECT * FROM Customers 
WHERE CustomerID=1;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: Provide an example of a SQL query using a comparison operator to filter results.

A
SELECT * FROM Customers 
WHERE CustomerID > 80;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: List some operators that can be used in the WHERE clause.

A

= : Equal
> : Greater than
< : Less than
>= : Greater than or equal
<= : Less than or equal
<> or != : Not equal
BETWEEN : Between a certain range
LIKE : Search for a pattern
IN : Specify multiple possible values for a column

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