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 LIKE 'Peter'

  2. SELECT * FROM Persons WHERE FirstName<>'Peter'

  3. SELECT [all] FROM Persons WHERE FirstName='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 can 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 LIKE 'Peter' - This option is incorrect because the "LIKE" operator is used for pattern matching and not for exact matching. In this case, we need to match the exact value of "Peter," so the "=" operator should be used instead.

Option B) SELECT * FROM Persons WHERE FirstName<>'Peter' - This option is incorrect because it selects all the records where the value of the column "FirstName" is not equal to "Peter." However, we want to select all the records where the value is equal to "Peter," so this option is not the correct choice.

Option C) SELECT [all] FROM Persons WHERE FirstName='Peter' - This option is incorrect because the keyword "all" is not necessary in the SELECT statement. The correct syntax is to use the asterisk (*) to select all columns.

Option D) SELECT * FROM Persons WHERE FirstName='Peter' - This option is correct because it selects all the records from the table "Persons" where the value of the column "FirstName" is equal to "Peter." This is the correct choice because it matches the given conditions.

The correct answer is D. SELECT * FROM Persons WHERE FirstName='Peter'. This option is correct because it selects the desired records where the value of the column "FirstName" is "Peter".

Find more quizzes: