O'Reilly logo

Microsoft® SQL Server® 2008 Bible by Uttam Parui, Mike White, Paul Nielsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Introducing 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 Query Optimizer, which then determines the best method to physically execute the query. As you'll see in the next eight chapters, there are often many ways of stating the query, but each method could be 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 and will be the easiest to maintain 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 built queries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required