Multiple choice technology databases

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

  1. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen' ;

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen' ;

  3. SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons ;

  4. SELECT LastName LIKE'%Hansen%' AND LastName LIKE '%Pettersen%' FROM Persons ;

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

BETWEEN is the correct operator for range selection and is inclusive of both endpoints. The > and < operators in option A would exclude the boundary values.