Database Reference
In-Depth Information
| 2014-05-14 09:31:37 | gene | venus | barb | mars | 2291 |
| 2014-05-14 11:52:17 | phil | mars | tricia | saturn | 5781 |
| 2014-05-14 14:42:21 | barb | venus | barb | venus | 98151 |
| 2014-05-14 17:03:01 | tricia | saturn | phil | venus | 2394482 |
| 2014-05-15 07:17:48 | gene | mars | gene | saturn | 3824 |
| 2014-05-15 08:50:57 | phil | venus | phil | venus | 978 |
| 2014-05-15 10:25:52 | gene | mars | tricia | saturn | 998532 |
| 2014-05-15 17:35:31 | gene | saturn | gene | mars | 3856 |
| 2014-05-16 09:00:28 | gene | venus | barb | mars | 613 |
| 2014-05-16 23:04:19 | phil | venus | barb | venus | 10294 |
| 2014-05-19 12:49:23 | phil | mars | tricia | saturn | 873 |
| 2014-05-19 22:21:51 | gene | saturn | gene | venus | 23992 |
+---------------------+---------+---------+---------+---------+---------+
To create and load the
mail
table, change location into the
tables
directory of the
rec
ipes
distribution and run this command:
%
mysql cookbook < mail.sql
This chapter also uses other tables from time to time. Some were used in previous
chapters, whereas others are new. To create any of them, do so the same way as for the
mail
table, using the appropriate script in the
tables
directory. In addition, many of the
other scripts and programs used in this chapter are located in the
select
directory. The
files in that directory enable you to try the examples more easily.
Many of the statements shown here can be executed from within the
mysql
program,
which is discussed in
Chapter 1
. A few examples involve issuing statements from within
the context of a programming language. See
Chapter 2
for information on programming
techniques.
3.1. Specifying Which Columns and Rows to Select
Problem
You want to display specific columns and rows from a table.
Solution
To indicate which columns to display, name them in the output column list. To indicate
which rows to display, use a
WHERE
clause that specifies conditions that rows must satisfy.
Discussion
The simplest way to display columns from a table is to use
SELECT
*
FROM
tbl_name
. The
*
specifier is a shortcut that means “all columns”: