SELECT Overview and Syntax

In many ways, the SELECT statement is the real heart of SQL. It lets you find and view your data in a variety of ways. You use it to answer questions based on your data: how many, where, what kind of, even what if. Once you become comfortable with its sometimes dauntingly complex syntax, you'll be amazed at what the SELECT statement can do.

Because SELECT is so important, five chapters focus on it:

  • This chapter begins with the bare bones: the SELECT, FROM, and WHERE clauses, search conditions, and expressions.

  • Chapter 5 delves into some SELECT refinements: ORDER BY, the DISTINCT keyword, and aggregates.

  • Chapter 6 covers the GROUP BY clause, the HAVING clause, and making reports from grouped data. Chapter 6 also summarizes the issues regarding null values in database management.

  • Chapter 7 introduces multiple-table queries with a comprehensive discussion of joining tables.

  • Chapter 8 moves on to nested queries, also known as subqueries.

Queries in this chapter use single tables so that you can focus on manipulating the syntax in a simple environment. Following is an example of a SELECT query—don't worry about the syntax yet:

SQL
select address
from publishers
where pub_id = '0877'
address
========================================
2 2nd Ave.
[1 row]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.237.77