SQL Projection — Specifying Columns to Display How do you specify the columns to display and the source tables in a standard SQL SELECT statement?

Difficulty: Easy

Correct Answer: Use FROM to name the source table(s) and list the columns to be shown after SELECT.

Explanation:


Introduction:
SQL separates the list of output columns (projection) from the list of input tables (data sources). Knowing which clause controls which part of the statement is a foundational skill for any SQL practitioner.


Given Data / Assumptions:

  • The canonical SELECT syntax is: SELECT column_list FROM table_list WHERE conditions ...
  • Some dialects support additional clauses (GROUP BY, HAVING, ORDER BY).
  • There is no generic USING clause for naming tables (USING exists only in join condition shorthand).


Concept / Approach:
Place the columns to project immediately after SELECT. Then use FROM to specify one or more source tables or views. Additional clauses refine which rows are returned and in what order, but they do not change the basic roles of SELECT and FROM.


Step-by-Step Solution:
1) Write SELECT followed by the comma-separated list of columns or *.2) Write FROM followed by one or more tables or views, with optional JOIN syntax.3) Optionally add WHERE, GROUP BY, HAVING, ORDER BY to further shape results.4) Conclude that option (a) correctly assigns responsibilities to SELECT and FROM.


Verification / Alternative check:
Every major RDBMS demonstrates these roles in beginner documentation. The USING keyword appears only as part of certain JOIN syntaxes and does not replace FROM for naming sources.


Why Other Options Are Wrong:

  • USING in place of FROM: Not valid; USING is a join shorthand within FROM.
  • Reversing the roles of SELECT and FROM: Contradicts standard syntax.
  • SHOW COLUMNS: That is a metadata command, not part of SELECT projection syntax.


Common Pitfalls:
Placing table names after SELECT or attempting to use nonstandard clauses for table naming. Keep the mental model: SELECT = columns, FROM = sources.


Final Answer:
Use FROM to name the source table(s) and list the columns to be shown after SELECT.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion