With SQL, how do you select a column named "FirstName" from a table named "Persons"?

  1. EXTRACT FirstName FROM Persons

  2. SELECT FirstName FROM Persons

  3. SELECT Persons.FirstName


Correct Option: B
Explanation:

To solve this question, the user needs to have a basic understanding of SQL and the syntax used to select specific columns from a table. In SQL, the SELECT statement is used to retrieve data from a database. The user must know how to specify the column name and the table name in the SELECT statement to retrieve the desired data.

Now, let's go through each option and explain why it is right or wrong:

A. EXTRACT FirstName FROM Persons: This option is incorrect. The EXTRACT keyword is used to retrieve date and time information from a specified value, not to select specific columns from a table.

B. SELECT FirstName FROM Persons: This option is correct. The SELECT statement followed by the column name (FirstName) and the table name (Persons) retrieves the data from the specified column in the specified table.

C. SELECT Persons.FirstName: This option is also correct. The SELECT statement can be written in the format of "SELECT TableName.ColumnName" to specify the table name and column name. In this case, the column name (FirstName) is preceded by the table name (Persons) and separated by a dot (.) to retrieve the desired data.

The Answer is: B

Find more quizzes: