PrevUpHomeNext

The join() Family of Functions

join()
inner_join()
left_join()
right_join()
full_join() (PostgreSQL only)
jump()
With a Collector Class
Self Joins

As a free function ...

The free function join() builds a query that produces all combinations of the outputs of some other queries. It's a wrapper for SQL's JOIN.

For any queries q0, q1, ..., you can call join(q0, q1, ...).

It returns a junction (that's a kind of query) with the following characteristics:

  • Its value type is std::tuple<T0, T1, ...>, where T0, T1 ... are the value types of q0, q1 ... respectively.
  • Its value mapper is a new tuple_mapper<T0, T1, ...), in which the i'th member mapper is identical to qi's value mapper.
  • Its output consists of std::tuples, formed from each combination of the outputs of q0, q1, ... .
Example
const query<std::tuple<cinema, screen, movie>> combinations =
    join(cinemas, screens, movies);
... or as a method

For any queries l, r, the call l.join(r) is equivalent to join(l, r).

Note that the join() method, unlike the join() free function, always makes queries that produce tuples of two elements. E.g. a.join(b).join(c) produces outputs of the form {( -- , -- }, -- }; whereas join(a, b, c) produces outputs of the form { -- , -- , -- }.

Example
const query<std::tuple<screen, movie>> possible_screenings =
    screens.join(movies);

PrevUpHomeNext