What is the purpose of the WHERE clause in a SELECT statement?
A
To sort the result B
To group data C
To filter rows based on a condition D
To delete data
Analysis & Theory
The WHERE clause is used to filter rows that meet a specified condition.
Which of the following is a correct use of the WHERE clause?
A
SELECT * WHERE name = 'John' FROM students; B
SELECT * FROM students WHERE name = 'John'; C
WHERE name = 'John' SELECT * FROM students; D
SELECT name = 'John' FROM students WHERE;
Analysis & Theory
The correct syntax is: SELECT * FROM students WHERE name = 'John';
What does the following query do? `SELECT * FROM products WHERE price > 100;`
A
Returns all products with price less than 100 B
Returns all products with price equal to 100 C
Returns all products with price greater than 100 D
Returns products with no price
Analysis & Theory
The condition `price > 100` filters only rows where the price is greater than 100.
Which operator is used in the WHERE clause for checking inequality?
A
= B
!= C
<=> D
==
Analysis & Theory
The `!=` operator is used to check if two values are not equal in MySQL.
What will the query `SELECT * FROM users WHERE age >= 18;` return?
A
Users exactly 18 years old B
Users under 18 C
Users 18 and older D
Users with no age
Analysis & Theory
The condition `age >= 18` selects users who are 18 or older.
Which logical operator is used to combine multiple conditions in a WHERE clause?
A
ADD B
JOIN C
AND D
MERGE
Analysis & Theory
The `AND` operator is used to combine multiple conditions in a WHERE clause.
How do you check if a column value is NULL in a WHERE clause?
A
WHERE column == NULL B
WHERE column != NULL C
WHERE column = NULL D
WHERE column IS NULL
Analysis & Theory
To check for NULL values, use `IS NULL` in the WHERE clause.
Which operator is used to match a value within a list in a WHERE clause?
A
BETWEEN B
IN C
LIKE D
IS
Analysis & Theory
The `IN` operator is used to test whether a value matches any value in a list.
Which keyword is used for pattern matching in WHERE clauses?
A
IN B
BETWEEN C
LIKE D
MATCH
Analysis & Theory
The `LIKE` keyword is used in WHERE clauses for pattern matching with wildcards.
What does `%` mean in a WHERE clause using LIKE?
A
Escape character B
Ends with a value C
Wildcard for any sequence of characters D
Wildcard for one character
Analysis & Theory
The `%` wildcard represents any number of characters in a pattern with LIKE.