For example, the database table named Clients contains information about people in the
following rows:
LastName
Tom
Peter
To add a record to the table, use the following statement:
INSERT INTO Clients
VALUES ('Smith', 'Kaleigh', '14 Greenway', 'Windham')
After the database management system processes the preceding statement, the table contains the
following rows:
LastName
Tom
Peter
Smith
Notice that the values inserted in the table were surrounded by single-quotation marks in the
statement. In SQL, you must surround any text or date values with single-quotation marks;
however, you don't use single-quotation marks with numeric values.
Alternatively, you can specify the columns for which you want to insert data. This approach lets
you insert data into some columns while omitting others. For this approach, you use the
following syntax:
INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)
For example, to add Kaleigh Smith of Windham, with an unknown address, you use the named
column approach:
INSERT INTO Clients (LastName, FirstName, City)
VALUES ('Smith', 'Kaleigh', 'Windham')
You use the
cfquery
statements to your data source. As described in
Development Environment" on page
to an indicated data provider, such as a relational database management system. The data source
that you established in that chapter stored information on how to access the Compass Travel
database. The data source name was "CompassTravel."
132
Chapter 12: Lesson 9: Enabling Database Maintenance
FirstName
Jones
Green
FirstName
Jones
Green
Kaleigh
tag to execute SQL from ColdFusion. The
49, a data source stores information about how to connect
Address
12 State St
1 Broadway
Address
12 State St
1 Broadway
14 Greenway
cfquery
"Lesson 2: Configuring Your
City
Boston
New York
City
Boston
New York
Windham
tag passes SQL
Need help?
Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?
Questions and answers