Java Reference
In-Depth Information
INSERT, DELETE and UPDATE, can cause problems with other
tables, as well as significant problems within the table you are working
on. Delete with care.
Caution
Data Query Language
Probably the most important function of any database application is the ability to
search for specific records or groups of records and return them in the desired form.
In SQL, this capability is provided by the Data Query Language (DQL). The process
of finding and returning formatted records is known as querying the database.
The SELECT Statement
The SELECT statement is the basis of data retrieval commands, or queries, to the
database. In addition to its use in returning data in a query, the SELECT statement
can be used in combination with other SQL commands to select data for a variety of
other operations, such as modifying specific records using the UPDATE command.
The basic form of a simple query specifies the names of the columns to be returned
and the name of the table or tables in which they can be found. A basic SELECT
command looks like this:
SELECT columnName1, columnName2,.. FROM tableName;
Using this query format, you can retrieve the first name and last name of each entry in
the Customers Table by using the following SQL command:
SELECT First_Name, Last_Name FROM Customers;
In addition to this form of the command, where the names of all the fields you want
returned are specified in the query, SQL supports this wild card form:
SELECT * FROM tableName;
The wild card, "*", tells the database management system to return the values for all
columns.
The WHERE Clause
Under normal circumstances, you probably do not want to return every row from a
table. A practical query needs to be more restrictive, returning the requested fields
from only records that match some specific criteria.
To make specific queries, use the WHERE clause. The WHERE clause was
introduced earlier in this chapter under the section " Data Manipulation Language ."
Search WWH ::




Custom Search