Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 1 SQL Building Blocks [Table of Contents] Chapter 3 Using Aggregates, Grouping,
and Sorting

Transact-SQL User's Guide

[-] Chapter 2 Queries: Selecting Data from a Table

Chapter 2

Queries: Selecting Data from a Table

The select command retrieves data stored in the rows and columns of database tables using a procedure called a query. A query has three main parts: the select clause, the from clause, and the where clause.

This chapter focuses on basic single-table select statements. Many sections contain sample statements that you can use to practice writing queries. If you want to integrate other Transact-SQL functionality, such as joins, subqueries, and aggregates, you can find more complex query examples later in this book.

[-] What are queries?
select syntax
[-] Choosing columns: the select clause
Choosing all columns: select *
Choosing specific columns
Rearranging the order of columns
Renaming columns in query results
[+] Expressions
[+] Selecting text and image values
Select list summary
Eliminating duplicate query results with distinct
Specifying tables: the from clause
[-] Selecting rows: the where clause
Comparison operators
Ranges (between and not between)
Lists (in and not in)
[-] Pattern matching
[+] Matching character strings: like
Character strings and quotation marks
[+] "Unknown" values: NULL
[+] Connecting conditions with logical operators


Using the pubs2 and pubs3 sample
databases [Table of Contents] What are queries?