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?

  1. In SQL, pattern matching is performed with LIKE clauses.
  2. An SQL query usually begins with a LIKE clause before a WHERE clause
  3. Using the LIKE clause in an SQL query, we compare the pattern in the query with the pattern present in a table.
  4. All of the above

Answer: D) All of the above

Explanation:

In case of Pattern Matching:

  1. In SQL, pattern matching is performed with LIKE clauses.
  2. An SQL query usually begins with a LIKE clause before a WHERE clause
  3. 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 –

  1. Strings
  2. Numbers
  3. Both A. and B.
  4. 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.

  1. /
  2. _
  3. *
  4. %

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.

  1. -
  2. _
  3. !
  4. &

Answer: B) _

Explanation:

In LIKE clause, to represent a single character, _ is used.

Discuss this Question


5. LIKE clause can be used with –

  1. % operator
  2. _ operator
  3. NOT operator
  4. 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%'
  1. Finds any values that start with "a"
  2. Finds any values that start with "a%"
  3. Finds any values that contains only two characters starting with "a"
  4. 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'
  1. Finds any values that end with "a"
  2. Finds any values whose second character is "a"
  3. Find any values that contains only two characters ending with "a"
  4. 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%'
  1. Finds any values that start with "or"
  2. Finds any value that contains only four characters and second, third characters are 'o', 'r'
  3. Finds any values that have "or" in any position
  4. 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_%'
  1. Finds any values that start with "a"
  2. Finds any values that start with "a%"
  3. Finds any values that start with "a" and are at least 2 characters in length
  4. 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'
  1. Finds any values that start with "a" and ends with "o"
  2. Finds any values whose first character is "a" and third character is "o"
  3. Both A. and B.
  4. 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





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.