Multiple choice technology databases

  1. 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='%a%'

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

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

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

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

The SQL LIKE operator with 'a%' matches any string starting with 'a'. The % wildcard matches zero or more characters. Option A ('%a%') would match any string containing 'a' anywhere. Option B is exact equality. Option C ('%a') matches strings ending with 'a'.