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 LIKE 'a%'

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


Correct Option: C

AI Explanation

To select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a", you can use the SQL query:

Option C) SELECT * FROM Persons WHERE FirstName LIKE 'a%'

Explanation for each option:

Option A) SELECT * FROM Persons WHERE FirstName LIKE '%a' This option is incorrect because the '%a' wildcard pattern at the end will match any value that ends with 'a', not just those that start with 'a'.

Option B) SELECT * FROM Persons WHERE FirstName='a' This option is incorrect because it will only select the records where the value of the column "FirstName" is exactly 'a', not those that start with 'a'.

Option C) SELECT * FROM Persons WHERE FirstName LIKE 'a%' This option is correct because the 'a%' wildcard pattern at the end will match any value that starts with 'a'. This is the correct way to select all the records where the value of the column "FirstName" starts with 'a'.

Option D) SELECT * FROM Persons WHERE FirstName='%a%' This option is incorrect because the '%a%' wildcard pattern on both sides will match any value that contains 'a', not just those that start with 'a'.

The correct answer is Option C) SELECT * FROM Persons WHERE FirstName LIKE 'a%'. This option is correct because it selects all the records where the value of the column "FirstName" starts with 'a'.

Find more quizzes: