ASA SQL User's Guide
Queries: Selecting Data from a Table
Query overview
In this manual, SELECT statements and other SQL statements appear with each clause on a separate row, and with the SQL keywords in upper case. This is not a requirement. You can type SQL keywords in any case, and you can break lines at any point.
For example, the following SELECT statement finds the first and last names of contacts living in California from the Contact table.
SELECT first_name, last_name FROM Contact WHERE state = 'CA'
It is equally valid, though not as readable, to enter this statement as follows:
SELECT first_name, last_name from contact wHere state = 'CA'
Identifiers (that is, table names, column names, and so on) are case insensitive in Adaptive Server Anywhere databases.
Strings are case insensitive by default, so that 'CA', 'ca', 'cA', and 'Ca' are equivalent, but if you create a database as case-sensitive then the case of strings is significant. The sample database is case insensitive.
You can qualify the names of database identifiers if there is ambiguity about which object is being referred to. For example, the sample database contains several tables with a column called city, so you may have to qualify references to city with the name of the table. In a larger database you may also have to use the name of the owner of the table to identify the table.
SELECT DBA.contact.city FROM contact WHERE state = 'CA'
Since the examples in this chapter involve single-table queries, column names in syntax models and examples are usually not qualified with the names of the tables or owners to which they belong.
These elements are left out for readability; it is never wrong to include qualifiers.
The remaining sections in this chapter analyze the syntax of the SELECT statement in more detail.