Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 413

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
In this case, you extract LastName and FirstName information from the employees table and Street, City, State, and
ZIP information from the addresses table. You can use output such as this is to generate mailing addresses for an
employee newsletter.
The results of a SELECT statement that references multiple tables is a single result table containing a join of the
information from corresponding rows. A join means information from two or more rows is combined to form a single
row of the result. In this case, the resultant recordset has the following structure:
LastName
FirstName
What is interesting in this result is that even though you used the EmpID field to combine information from the two
tables, you did not include that field in the output.
Modifying a database
You can use SQL to modify a database in the following ways:
Inserting data into a database
You use SQL INSERT statement to write information to a database. A write adds a new row to a database table. The
basic syntax of an INSERT statement is as follows:
INSERT INTO table_name(column_names) VALUES(value_list)
where:
• column_names specifies a comma-separated list of columns.
• value_list specifies a comma-separated list of values. The order of values has to correspond to the order that you
specified column names.
Note: There are additional options to INSERT depending on your database. For a complete syntax description for
INSERT, see the product documentation.
For example, the following SQL statement adds a new row to the employees table:
INSERT INTO employees(EmpID, LastName, Firstname) VALUES(51, 'Smith', 'John')
This statement creates a row in the employees table and sets the values of the EmpID, LastName, and FirstName fields
of the row. The remaining fields in the row are set to Null. Nullmeans that the field does not contain a value.
When you, or your database administrator, creates a table, you can set properties on the table and the columns of the
table. One of the properties you can set for a column is whether the field supports Null values. If a field supports Nulls,
you can omit the field from the INSERT statement. The database automatically sets the field to Null when you insert
a new row.
Street
City
Last updated 1/20/2012
State
Zip
408

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents