This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Where Clause”.
1. WHERE clause is used to filter ________
a) Rows
b) Groups
c) Columns
d) Tables
View Answer
Explanation: HAVING is used to filter groups. WHERE is used to filter rows. It filters out the unwanted data records. SELECT is used to filter columns.
2. Which of the following is used to extract only those records that fulfill a specified condition?
a) Select
b) Where
c) From
d) Having
View Answer
Explanation: Select is used to retrieve data records. Where clause filters rows of a table and extracts only those records that fulfill the given condition. From is used to identify a table.
3. WHERE keyword can be used to filter data by matching patterns.
a) True
b) False
View Answer
Explanation: Whenever we want to retrieve the data that resembles a pattern, WHERE clause can be used. This pattern can use ‘_’ and ‘%’ characters along with alphabets.
4. Which of the following is the correct order of clauses in a basic SQL statement?
a) Select, Where
b) Select, Where, From
c) Select, From, Where
d) From, Where
View Answer
Explanation:
SELECT column_list FROM TABLE_NAME WHERE condition;
This is the syntax for a basic SQL statement, which retrieves the columns named in column_list based on the given condition.
5. WHERE clause cannot be used with _________
a) Select
b) Delete
c) Drop
d) Update
View Answer
Explanation: Where clause can be used along with Select, Delete Update commands. But it cannot be used with Drop command to delete a table.
6. Operators can be used in WHERE clause.
a) True
b) False
View Answer
Explanation: Operators can be used in WHERE clause to filter the data based on the required conditions. These operators are mostly used to compare the values of the fields with other fields or with other constants.
7. Which of the following requires single quotes in SQL?
a) Numeric fields
b) Clauses
c) Text fields
d) Columns
View Answer
Explanation: SQL requires single quotes around text values. However, numeric fields, Clauses and Columns should not be enclosed in any quotes.
8. Which operator in the where clause signifies “Not Equal”?
a) <>
b) <!>
c) <_>
d) <->
View Answer
Explanation: <> denotes not equal. In some versions of SQL “!=” is also used for not equal. Rests of the options are not valid operators and therefore, they are not used in SQL.
9. Which operator is used to search for a pattern?
a) Between
b) In
c) Like
d) =
View Answer
Explanation: Like operator is used to search for a pattern. Between is used to search for values in an inclusive range. In is used to specify multiple possible values for a column. = is used to determine whether the value is equal or not.
10. Which of the following is not a valid operator and is not used in WHERE clause?
a) =
b) ==
c) <=
d) >=
View Answer
Explanation: = denotes equal to. <= denotes less than or equal to. >= denotes greater than or equal to. == is not a valid operator in SQL and it is not used with where clause.
Sanfoundry Global Education & Learning Series – SQL.
To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]