
Crestron e-control Database Manager SW-DBM
35 •• The Database File Installation & Reference Guide — DOC. 5823
T.Minutes AS ["],
T.Seconds AS [']
FROM Albums A
INNER JOIN Tracks T
ON A.CDJID = T.CDJID
Note the following syntax features of SQL, all illustrated in the above example:
• Dot syntax. When the same field name is used in more than one table, you
must use the syntax table.field to eliminate ambiguity. In the above example,
this syntax was used throughout, although in fact the fields Artist and
Track did not actually appear in both tables.
• Table name aliases. The FROM clause assigns the alias A to the Albums
table and T to the Tracks table. Once these aliases are established, you
can use them instead of the full table names in the listFields and dataFields
columns.
• Captions. Use the word AS after a field name in the SELECT clause to
introduce a caption. In the above, ARTIST, ALBUM, CUT, etc. are
captions. Unlike a table name alias, you cannot refer to the field using its
caption. Captions, when defined, are displayed in place of the field name in
reports generated with Microsoft Access. The server also uses captions during
successive queries. The captions are inserted as data into the description string
and transmitted to the control system via the QueryDescription signal. If the
caption is not defined here, the field name is used instead.
• Square brackets are used around any table names, field names, and captions
that contain spaces or punctuation.
Outer joins are also supported. A LEFT JOIN includes all rows from the first table in
the output, even if it has no matching rows in the second table. A RIGHT JOIN
includes all rows from the second table even if it has no matching rows in the first
table. With an outer join, matching rows are still matched and the selected columns
from the two tables are strung together in one record. Any row that is included that
does not have a matching row in the other table is assigned default values for the
additional columns – zero for numeric columns and blank for character columns.
The Queries Table
You do not need to know SQL or Microsoft Access to construct a query for use by
the scroller signal blocks in the Crestron Software Server. In the server application,
you construct queries using a special database table named Queries.
This requires that each database you create contain at least two tables, the table with
the data for your application and a Queries table. For example, the Address Book
database contains two tables, Addresses and Queries:
The database window from Microsoft Access, showing the two tables in the AddrBook database..
Komentáře k této Příručce