Joins

Joining with from

A two table join :

The select clause can return anything that is in the scope, for example it
could return both joined objects with a Tuple2 : select((s, ple))

The join keyword

produces :

A join can also be an agreate query, for example :

The type of this query is Query[GroupWithMeasures[(Long,String),Long], it produces the following SQL :

Of course, like in SQL, a join can have a where clause :

If a join has N arguments, the ‘on’ function must take N-1 arguments,
the i’th ‘on’ condition corresponds to the i’th table expression :

Outer Joins

A Left Outer Join is done by calling leftOuterJoin within the select clause,
where the fist parameter is the row object variable, and the second a boolean clause.

This query returns the joined objects in a tuple, leftOuterJoin causes the second tuple
member to be an Option[Rating]

The signatures of (left, right and full) outer joins ensure that the null part of the
outer join returns an Option[]

leftOuterJoin[A](a: A, b: =>LogicalBoolean): Option[A]

rightOuterJoin[A,B](a: A, b: B, c: =>LogicalBoolean): (Option[A], B)

fullOuterJoin[A,B](a: A, b:B, c: =>LogicalBoolean): (Option[A], Option[B])

The SQL of the previous query is :