SQL Questions and Answers – SQL Where Clause

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

Answer: a
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

Answer: b
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

Answer: a
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.
advertisement
advertisement

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

Answer: c
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

Answer: c
Explanation: Where clause can be used along with Select, Delete Update commands. But it cannot be used with Drop command to delete a table.
advertisement

6. Operators can be used in WHERE clause.
a) True
b) False
View Answer

Answer: a
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

Answer: c
Explanation: SQL requires single quotes around text values. However, numeric fields, Clauses and Columns should not be enclosed in any quotes.
advertisement

8. Which operator in the where clause signifies “Not Equal”?
a) <>
b) <!>
c) <_>
d) <->
View Answer

Answer: a
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

Answer: c
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

Answer: b
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]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.