Which SQL statement is equivalent to: SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';

Difficulty: Easy

Correct Answer: SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');

Explanation:


Introduction / Context:
Different but equivalent SQL predicates can express the same filter. Equality to a single value and membership in a single-item set are interchangeable in most DBMSs.



Given Data / Assumptions:

  • Original query: SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';
  • We seek a logically equivalent statement using valid SQL syntax.


Concept / Approach:
The predicate STATE = 'VA' is equivalent to STATE IN ('VA') because the IN list contains exactly one element. The rest of the statement (SELECT columns and FROM table) must remain syntactically correct.



Step-by-Step Solution:

Compare options and discard those using invalid 'IN' placement (must be after WHERE with a column expression).Ensure FROM appears before the table name and WHERE after it.Select the option that preserves SELECT ... FROM ... WHERE ... and uses IN ('VA').


Verification / Alternative check:
Run both queries; they return identical result sets in any standard SQL engine.



Why Other Options Are Wrong:
Options A, B, C: Misuse 'IN' directly after SELECT or omit FROM; also C changes the value to 'V' which is not equivalent. They are syntactically incorrect or semantically different.



Common Pitfalls:
Forgetting that IN requires parentheses and a list; placing IN after SELECT rather than as part of the WHERE condition.



Final Answer:
SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion