Home »
SQL »
SQL MCQs
MCQ | SQL – Pattern Matching
SQL Pattern Matching MCQ: This section contains the Multiple-Choice Questions & Answers on SQL Pattern Matching.
Submitted by Anushree Goswami, on October 31, 2021
SQL Pattern Matching MCQs
1. Which of the following is TRUE about Pattern Matching in SQL?
- In SQL, pattern matching is performed with LIKE clauses.
- An SQL query usually begins with a LIKE clause before a WHERE clause
- Using the LIKE clause in an SQL query, we compare the pattern in the query with the pattern present in a table.
- All of the above
Answer: D) All of the above
Explanation:
In case of Pattern Matching:
- In SQL, pattern matching is performed with LIKE clauses.
- An SQL query usually begins with a LIKE clause before a WHERE clause
- Using the LIKE clause in an SQL query, we compare the pattern in the query with the pattern present in a table.
Discuss this Question
2. It is possible to use LIKE clauses with –
- Strings
- Numbers
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
It is possible to use LIKE clauses with strings and numbers.
Discuss this Question
3. In LIKE clause, to represent a zero, a character, or a number of characters ___ is used.
- /
- _
- *
- %
Answer: D) %
Explanation:
In LIKE clause, to represent a zero, a character, or a number of characters % is used.
Discuss this Question
4. In LIKE clause, to represent a single character, _____ is used.
- -
- _
- !
- &
Answer: B) _
Explanation:
In LIKE clause, to represent a single character, _ is used.
Discuss this Question
5. LIKE clause can be used with –
- % operator
- _ operator
- NOT operator
- All of the above
Answer: D) All of the above
Explanation:
LIKE clause can be used with % , _ and NOT operators.
Discuss this Question
6. What does the following statement do?
WHERE CustomerName LIKE 'a%'
- Finds any values that start with "a"
- Finds any values that start with "a%"
- Finds any values that contains only two characters starting with "a"
- All of the above
Answer: A) Finds any values that start with "a"
Explanation:
The above statement finds any values that start with "a"
Discuss this Question
7. What does the following statement do?
WHERE CustomerName LIKE '%a'
- Finds any values that end with "a"
- Finds any values whose second character is "a"
- Find any values that contains only two characters ending with "a"
- Mysql > Savepoint ini;
Answer: A) Finds any values that end with "a"
Explanation:
The above statement finds any values that end with "a"
Discuss this Question
8. What does the following statement do?
WHERE CustomerName LIKE '%or%'
- Finds any values that start with "or"
- Finds any value that contains only four characters and second, third characters are 'o', 'r'
- Finds any values that have "or" in any position
- None of the above
Answer: C) Finds any values that have "or" in any position
Explanation:
The above statement finds any values that have "or" in any position
Discuss this Question
9. What does the following statement do?
WHERE CustomerName LIKE 'a_%'
- Finds any values that start with "a"
- Finds any values that start with "a%"
- Finds any values that start with "a" and are at least 2 characters in length
- All of the above
Answer: C) Finds any values that start with "a" and are at least 2 characters in length
Explanation:
The above statement finds any values that start with "a" and are at least 2 characters in length
Discuss this Question
10. What does the following statement do?
WHERE ContactName LIKE 'a%o'
- Finds any values that start with "a" and ends with "o"
- Finds any values whose first character is "a" and third character is "o"
- Both A. and B.
- None of the above
Answer: A) Finds any values that start with "a" and ends with "o"
Explanation:
The above statement finds any values that start with "a" and ends with "o"
Discuss this Question