Difficulty: Easy
Correct Answer: LIKE only
Explanation:
Introduction / Context:Filtering text using patterns is a frequent requirement. In standard SQL, wildcards are applied with a specific predicate that understands special characters such as percent and underscore.
Given Data / Assumptions:
Concept / Approach:The keyword LIKE evaluates a string against a pattern containing wildcards. IN and NOT IN test membership in a list or subquery result and do not interpret wildcards. Some legacy dialects have a MATCHES operator, but it is not part of standard SQL.
Step-by-Step Solution:
Identify the need: pattern-based filtering.Apply LIKE with % or _ as needed, for example: WHERE name LIKE 'Ann%'.Exclude list-membership predicates that ignore wildcards.Verification / Alternative check:Run: SELECT * FROM t WHERE code LIKE 'A_3'; This returns rows where code has 'A', then any one character, then '3'.
Why Other Options Are Wrong:
Common Pitfalls:For case-insensitive matching, use functions or collations as appropriate. Avoid leading wildcards like '%term' on large tables without indexes suited for such searches.
Final Answer:LIKE only
Discussion & Comments