The queries in the previous section performed an implicit join. A join occurs whenever we need to navigate across two or more entities. We have seen that we cannot construct a composite path expression from a collection association-field. This prevents us from navigating across a one-to-many or many-to-many entity relationship. We can do this explicitly using one of the JOIN
operators.
Take a look at the following query:
SELECT c.lastName, a.addressLine FROM Customer c
INNER JOIN c.addresses a
For each customer this will retrieve their last name and all associated address lines (recall a customer can have more than one address in our model). The identification variable a
is defined by the path expression c.addresses
, and this identification variable is used in the expression a.addressLine
. In the case of an inner join, if a customer does not have an address then the customer's last name will not be retrieved by the above query. Note that the use of the keyword INNER
is optional...