Join

Adds columns from another table, matching rows based on a condition.

join side:{inner|left|right|full} {table} {[conditions]}

Parameters

  • side decides which rows to include. Defaults to inner
  • Table reference
  • List of conditions
    • If all terms are column identifiers, this will compile to USING(...). In this case, both tables must contain specified columns. The result will only contain one column for each specified column.

Examples

PRQL

from employees
join side:left positions [id==employee_id]

SQL

SELECT
  employees.*,
  positions.*
FROM
  employees
  LEFT JOIN positions ON id = employee_id

PRQL

from employees
join side:full positions [emp_no]

SQL

SELECT
  employees.*,
  positions.*,
  emp_no
FROM
  employees FULL
  JOIN positions USING(emp_no)

PRQL

from employees
join side:left p=positions [id==employee_id]

SQL

SELECT
  employees.*,
  p.*
FROM
  employees
  LEFT JOIN positions AS p ON id = employee_id