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

  1. SELECT [all] FROM Persons WHERE FirstName='Peter'

  2. SELECT * FROM Persons WHERE FirstName LIKE 'Peter'

  3. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

  4. SELECT * FROM Persons WHERE FirstName='Peter'


Correct Option: D

AI Explanation

To select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter", you would use the following SQL query:

D. SELECT * FROM Persons WHERE FirstName='Peter'

Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT [all] FROM Persons WHERE FirstName='Peter' This option is incorrect because the keyword "all" is not needed to select all records. The asterisk (*) symbol is used to select all columns.

Option B) SELECT * FROM Persons WHERE FirstName LIKE 'Peter' This option is incorrect because the "LIKE" keyword is used for pattern matching, not for exact matches. In this case, we need an exact match, so the "=" operator should be used instead of "LIKE".

Option C) SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter' Similar to Option A, this option is incorrect because the keyword "all" is not needed to select all records. The asterisk (*) symbol is used to select all columns.

Option D) SELECT * FROM Persons WHERE FirstName='Peter' This option is correct because it selects all columns (*) from the "Persons" table where the value of the "FirstName" column is exactly "Peter".

The correct answer is D.

Find more quizzes: