ADVERTISEMENT
ADVERTISEMENT

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

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.

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.


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.


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.


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.


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"


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"


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


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


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"


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.