In SQL, the LIKE operator is used for pattern matching with wildcard characters: the underscore () represents exactly one character, and the percent sign (%) represents zero or more characters. Using LIKE 'D%' matches any CITY value that starts with 'D', followed by at least one required character (matched by ), and then zero or more additional characters (matched by %) — correctly filtering for cities beginning with D that have additional characters after it. The '=' operator (used in options B and D) does not interpret '' or '%' as wildcards; it performs an exact string comparison, so those queries would only match a literal string containing a percent sign or underscore character, not perform pattern matching. Option C ('D_') restricts results to exactly two-character city names starting with D, which is overly restrictive and does not allow for city names longer than two characters.
Community Discussion