Reading data from tables Which SQL statement is used to query (read) data from a table or view and return a result set to the client?

Difficulty: Easy

Correct Answer: SELECT

Explanation:


Introduction / Context:
The most common SQL operation is reading data. Knowing the precise keyword that initiates a query helps differentiate between standard SQL and vendor-specific commands, and avoids confusion with cursor operations or procedural code.



Given Data / Assumptions:

  • We want a statement that retrieves data.
  • We are using ANSI-standard SQL syntax.
  • Results should be returned as a set of rows and columns.


Concept / Approach:

The SELECT statement projects columns, filters rows, groups, aggregates, and joins tables to produce a relational result set. Other words like READ or QUERY are English descriptions, not SQL keywords. FETCH exists but is used with cursors to retrieve the next row from an already opened result set, not to issue the initial query.



Step-by-Step Solution:

Issue SELECT ... FROM ... to define the data source.Add optional WHERE, GROUP BY, HAVING, ORDER BY for filtering, aggregation, and sorting.Return the resulting dataset to the client or next processing step.


Verification / Alternative check:

Every SQL reference begins with the SELECT statement to demonstrate data retrieval operations.



Why Other Options Are Wrong:

  • READ/QUERY: not SQL keywords.
  • FETCH: used with cursors after a SELECT has been executed.
  • D: Incorrect because SELECT is correct.


Common Pitfalls:

  • Confusing FETCH (cursor navigation) with issuing a SELECT.
  • Relying on SELECT * in production; specify columns for stability and performance.


Final Answer:

SELECT

Discussion & Comments

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