Performing Queries [ Up and Running with ALLBASE/SQL ] MPE/iX 5.0 Documentation
Up and Running with ALLBASE/SQL
Performing Queries
After loading your tables, you are ready to perform some queries to see
the result of your efforts at data definition and data entry. Use the
SELECT command to display the information you need.
The simplest form of SELECT uses the asterisk (*) to indicate that you
want to retrieve all the rows and columns in the table:
isql=> SELECT * FROM Titles; Return
This command retrieves all columns for all rows in the Titles table.
You can add a predicate (a WHERE clause) to narrow the range of rows
selected to a specific subgroup. In the following example, the predicate
evaluates a column in the table (Composer) against a constant value
('Palestrina'):
isql=> SELECT * FROM Titles Return
> WHERE Composer = 'Palestrina'; Return
This retrieves all rows in the Titles table whose composer is Palestrina.
You can use a column list to narrow the range of columns selected to a
specific group:
isql=> SELECT AlbumTitle, Return
> AlbumCost from Albums Return
> WHERE Medium = 'cd'; Return
A query that retrieves information from more than one table is known as a
join. In a two-table join, at least one predicate evaluates a column in
the first table against a column in the second. For example, the
following join query displays all album titles and selections that have
the same album code, drawing on the rows in both the Albums and the
Titles tables:
isql=> SELECT AlbumTitle, Selection Return
> FROM Albums, Titles WHERE Return
> Albums.AlbumCode = Titles.AlbumCode; Return
Notice that the AlbumCode column has to be qualified by its table name
because it appears in both tables. For additional information about
queries, refer to the "SQL Queries" chapter of the ALLBASE/SQL Reference
Manual.
MPE/iX 5.0 Documentation