Multiple choice technology databases

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

  1. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  2. SELECT * FROM Persons WHERE FirstName='%a%'

  3. SELECT * FROM Persons WHERE FirstName='a'

  4. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

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

The LIKE operator with 'a%' matches any string starting with 'a' followed by any characters. The % is a wildcard representing zero or more characters. Option A's '%a' matches ending with 'a', B's syntax is invalid, C matches only exact 'a', and D's 'a%' correctly matches starting with 'a'.