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" is "Peter"?

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

  2. SELECT * FROM Persons WHERE FirstName='Peter' ;

  3. SELECT * FROM Persons WHERE FirstName LIKE 'Peter' ;

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

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

The correct syntax is 'SELECT * FROM Persons WHERE FirstName='Peter'' which uses the WHERE clause with an equality operator. Option A incorrectly uses square brackets, while options C and D use LIKE operator which is for pattern matching, not exact values. The WHERE clause filters rows based on specified conditions.

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:

B. SELECT * FROM Persons WHERE FirstName='Peter';

Explanation:

  • The "SELECT" statement is used to retrieve data from a database table.
  • The asterisk (*) is a wildcard character that represents all columns in the table.
  • "FROM Persons" specifies the table name from which the data will be retrieved.
  • "WHERE FirstName='Peter'" is the condition that filters the records to only those where the value of the "FirstName" column is "Peter".