Bird
Raised Fist0

You want to select all customers from the Customers table who live in either 'New York' or 'Los Angeles'. Which WHERE clause correctly filters this?

hard🚀 Application Q8 of Q15
C Sharp (C#) - LINQ Fundamentals

You want to select all customers from the Customers table who live in either 'New York' or 'Los Angeles'. Which WHERE clause correctly filters this?

AWHERE City IN ('New York', 'Los Angeles')
BWHERE City = New York OR City = Los Angeles
CWHERE City = 'New York' AND City = 'Los Angeles'
DWHERE City LIKE 'New York' OR 'Los Angeles'"
Step-by-Step Solution
Solution:
  1. Step 1: Understand filtering for multiple values

    To select rows where City matches one of several values, use IN clause.
  2. Step 2: Evaluate options

    WHERE City IN ('New York', 'Los Angeles') uses IN correctly; the OR version lacks quotes around city names with spaces, causing syntax error; AND version cannot be true simultaneously; LIKE version has invalid syntax.
  3. Final Answer:

    WHERE City IN ('New York', 'Los Angeles') -> Option A
  4. Quick Check:

    Use IN for multiple value matching [OK]
Quick Trick: Use IN for multiple values in WHERE [OK]
Common Mistakes:
MISTAKES
  • Using AND instead of OR
  • Incorrect LIKE syntax
  • Not using quotes for strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes