Skip to Content
SQL Bible, Second Edition
book

SQL Bible, Second Edition

by Alex Kriegel, Boris M. Trukhnov
April 2008
Intermediate to advanced
888 pages
19h 35m
English
Wiley
Content preview from SQL Bible, Second Edition

Chapter 8. Understanding the SELECT Statement

This chapter covers selecting data from the RDBMS tables using the SELECT statement. As the name implies, it deals with selecting data from the RDBMS objects — tables or views — either to be presented to the users, or for some internal purpose. This is the only statement of the data query language (DQL) group.

The use of SELECT is relatively simple, but it rarely executes without optional clauses, and that's where the fun begins. The SELECT statement clauses are probably the most confusing in SQL and have to be dealt with accordingly. This chapter introduces the topic, covering the use of sub-queries, compound operators, aggregate functions, and more.

Tip

If you want to follow the SQL examples in this chapter and in the following chapters, you can download and run a set of SQL scripts that create (or re-create, if necessary) ACME tables in the RDBMS of your choice (Oracle 11 g, DB2 9.5, or Microsoft SQL Server 2008) and populate them with sample data. Follow links on the accompanying SQL Bible website.

Single Table SELECT Statement Syntax

Following is the generic SELECT statement, as it is defined by the SQL:2003 standard, for selecting data from a single table. The query includes the SELECT command, followed by the list of identifiers (table or view columns); then comes the mandatory FROM clause (optional in Microsoft SQL Server 2008) that contains names of the tables, from which these columns are selected.

The rest of the clause is optional, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

SQL All-In-One For Dummies, 3rd Edition

SQL All-In-One For Dummies, 3rd Edition

Allen G. Taylor

Publisher Resources

ISBN: 9780470229064Purchase book