SQL Questions and Answers – SQL Wildcards

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Wildcards”.

1. A wildcard operator is used to _________ any other character(s) in a string.
a) Substitute
b) Eliminate
c) Modify
d) Shift
View Answer

Answer: a
Explanation: Wildcard operators are used as an alternate for one or more than one characters while searching. A wildcard operator is used to substitute other characters in a string.

2. Wildcard characters are used with which of the following operators?
a) Between
b) Range
c) In
d) Like
View Answer

Answer: d
Explanation: Wildcard characters are used with the SQL LIKE operator. This LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

3. How many wildcards can be used with LIKE operator in SQL?
a) One
b) Two
c) Three
d) Four
View Answer

Answer: b
Explanation: Two wildcards can be used with the LIKE operator. They are % and _. % represents zero or more characters. _ represents a single character.
advertisement
advertisement

4. Which of the following wildcards can be used in MS Access and SQL server?
a) [char list], [ _ ]
b) [char list], [!char list]
c) [%], [ _ ]
d) [^char list], [ _ ]
View Answer

Answer: b
Explanation: MS Access uses a question mark (?) instead of underscore (_). MS Access and SQL server can use [char list] and [!char list] wildcards.

5. [char list] wildcard represents _______
a) Set of characters only
b) Range of characters only
c) Sets and ranges of characters to match
d) Domain of characters to match
View Answer

Answer: c
Explanation: [char list] defines sets and ranges of characters to match. It is used to fetch matching set or range of characters specified inside the brackets.

6. [^ char list] is used to fetch ___________ set or range of characters specified in the char list.
a) Matching
b) Non Matching
c) Deleted
d) Updated
View Answer

Answer: b
Explanation: [^ char list] and [! char list] represents same wildcard. It is used to fetch non-matching set or range of characters specified in the char list inside the brackets.

7. Which of the following is a correct syntax that uses [char list] wildcard?
a)

advertisement
SELECT *
FROM TABLE_NAME
WHERE  column_name LIKE[xyz]%’;

b)

advertisement
SELECT *
FROM TABLE_NAME
WHERE  column_name LIKE[xyz]’’%’;

c)

SELECT *
FROM TABLE_NAME
WHERE  column_name LIKE _‘[x-z]’;

d)

SELECT *
FROM TABLE_NAME
WHERE  column_name LIKE[xyz]’%;
View Answer
Answer: a
Explanation: [char list] is a wildcard, in which char list Specifies ranges of characters and sets to match. To match a pattern using LIKE operator, the whole pattern must be enclosed in single quotations.

8. Which of the following pattern is used to search for a string which doesn’t starts with letters from m to r and ends with at least 2 characters?
a) [m-r]%%
b) [!m-r]_ _ %
c) [^mr]_ %
d) [m-r]_ % _
View Answer

Answer: b
Explanation: Using this [!char list], we can specify more than one character in ‘char list’ to search and not to match them in a given string. _ Character matches with exactly one character. % character matches one or more characters.

9. Wildcards cannot be used as a substitute for special characters i.e. characters other than alphabets.
a) True
b) False
View Answer

Answer: b
Explanation: Wildcards can be used in the place of special characters. To search for a string with value ‘a@bc’, we can use ‘a%bc’ or ‘a_bc’ patterns in LIKE 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.