SQL-J Language Reference
Page 33 of 121

FROM clause

The FROM clause is a mandatory clause in a SelectExpression. It specifies the real or virtual tables from which the other clauses of the query can access columns for use in expressions.

Syntax

FROM [ PROPERTIES joinOrder = { FIXED | UNFIXED } ]
     TableExpression [ , TableExpression ]*

The optional PROPERTIES clause before the TableExpressions allows you to "fix" a particular join order--the order of items as they appear in the FROM clause. Otherwise, the optimizer makes its own choice about join order. For more information, see joinOrder in Tuning Cloudscape.

FROM clause Examples

SELECT Cities.city_id, Cities.city.showTemperature()
FROM Cities
WHERE city_id < 5

-- other types of TableExpressions
SELECT *
FROM sys.sysconglomerates AS C JOIN sys.systables AS T
USING (tableid)
WHERE T.tablename = 'CITIES'

-- force the join order
SELECT *
FROM Flights, FlightAvailability
WHERE FlightAvailability.flight_id = Flights.flight_id
AND FlightAvailability.segment_number = Flights.segment_number
AND Flights.flight_id < 'AA1115'

-- a TableExpression can be a joinOperation. Therefore
-- you can have multiple join operations in a FROM clause
SELECT country, city.getName(), hotel_name, normal_rate
FROM COUNTRIES LEFT OUTER JOIN Cities
ON Countries.country_ISO_code=Cities.country_ISO_code
LEFT OUTER JOIN Hotels
ON Cities.city_id=Hotels.city_id