Chapter 7. Understanding Basic Query Flow
In This Chapter
Logical flow of the query
Restricting the result set
Projecting data
Specifying the sort order
SQL is the romance language of data, but wooing the single correct answer from gigabytes of relational data can seem overwhelming until the logical flow of the query is mastered.
One of the first points to understand is that SQL is a declarative language. This means that the SQL query logically describes the question to the SQL Optimizer, which then determines the best method to physically execute the query. As you'll see in the next nine chapters, many ways of stating the query often exist, but each method is usually optimized to the same query-execution plan. This means you are free to express the SQL query in the way that makes the most sense to you. In some cases, one method is considered cleaner or faster than another: I'll point those instances out as well.
SQL queries aren't limited to select
. The four Data Manipulation Language (DML) commands, select, insert, update
, and delete
, are sometimes taught as four separate and distinct commands. However, I see queries as a single structural method of manipulating data; in other words, it's better to think of the four commands as four verbs that may each be used with the full power and flexibility of the SQL.
Neither are SQL queries limited to graphical interfaces. Many SQL developers who came up through the ranks from Access and who have only built queries using the Access query interface ...
Get SQL Server™ 2005 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.