The left_join()
method is similar to inner_join() except that its output includes every
output of the left-hand query at least once. It's a wrapper for SQL's
LEFT JOIN.
For any queries l, r,
you can call l.left_join(r, condition) provided that:
condition is an abstract_mapper<bool> (in practice it will be a predicate), and
r's value type cannot be represented as
all NULLs (which is unlikely to arise, but see
here for a discussion
of which types allow all NULLs).
l and r's value
mappers will both be visible
to condition.
l.left_join(r, condition) returns a conditional_junction
with the following characteristics:
std::tuple<Tl, boost::optional<Tr>>, where Tl
and Tr are l
and r's value types respectively.
tuple_mapper<Tl, boost::optional<Tr>>, in which:
l's
value mapper, and
optional_mapper<Tr> whose content mapper is
identical to r's value mapper.
std::tuples formed from each combination
of the outputs of l and r,
for which condition evaluates to
true, and
{lo, boost::none}, for each of l's
outputs lo that would not have made
an appearance otherwise.
const query<std::tuple<screen, boost::optional<movie>>> no_screen_left_behind = screens.left_join(movies, screens->current_movie_id == movies->id);