nerdexam
CompTIA

LX0-104 · Question #241

Which of the following SQL statements will select the fields name and address from the contacts table?

The correct answer is C. SELECT name, address FROM contacts. This question tests the basic SQL syntax for selecting multiple columns from a table.

Shells, Scripting and Data Management

Question

Which of the following SQL statements will select the fields name and address from the contacts table?

Options

  • ASELECT (name, address) FROM contacts;
  • BSELECT (name address) FROM contacts;
  • CSELECT name, address FROM contacts;
  • DSELECT name address FROM contacts;

How the community answered

(42 responses)
  • A
    2% (1)
  • B
    5% (2)
  • C
    90% (38)
  • D
    2% (1)

Why each option

This question tests the basic SQL syntax for selecting multiple columns from a table.

ASELECT (name, address) FROM contacts;

Parentheses around the column list (name, address) are not standard SQL syntax for selecting multiple columns and would result in a syntax error.

BSELECT (name address) FROM contacts;

Parentheses around the column list (name address) with no separator between column names is incorrect SQL syntax and would cause an error.

CSELECT name, address FROM contacts;Correct

In SQL, multiple column names are listed after the SELECT keyword, separated by commas, to retrieve data from those specific columns. The FROM clause then specifies the table from which to retrieve the data.

DSELECT name address FROM contacts;

Listing column names name address without a comma separator is incorrect SQL syntax for selecting multiple columns and would result in an error.

Concept tested: Basic SQL SELECT statement syntax

Source: https://learn.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql

Topics

#SQL#SELECT statement#database queries

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice