The only SQL command used to query database data is SELECT.
This command acts at the table level, and always produces a set as its result.
If a certain query returns exactly one row, or no rows at all, the result is still a set: a table with one row or the empty table, respectively.
The SELECT command has six main components, which implement all SQL retrieval.
The following table lists a high-level description of the roles of these six components of the SELECT command.
Component | Description |
---|---|
FROM | table(s) is (are) needed for retrieval |
WHERE | condition to filter the rows? |
GROUP BY | How should the rows be grouped/aggregated? |
HAVING | the condition to filter the aggregated groups? |
SELECT | Which columns do you want to see in the result? |
ORDER BY | In which order do you want to see the resulting rows? |