Multiple choice technology databases

If there are 3 persons with last names JOHN, J and JAMES how many of them are included in the result set of the query "SELECT LAST_NAME FROM STAFF WHERE LAST_NAME BETWEEN 'A' AND 'J'"

  1. 3

  2. 2

  3. 1

  4. 0

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

SQL BETWEEN is inclusive, so BETWEEN 'A' AND 'J' includes strings starting with both 'A' and 'J'. However, lexicographic ordering means 'JAMES' > 'J' (since 'JAMES' has more characters). Only 'JOHN' falls between 'A' and 'J' because 'J' alone matches the upper bound. The result is 1 row.