Starcounter
Home
Download
Docs
Community
Search…
2.3.2
Starcounter Documentation
Getting Started
Starcounter
Hello World - Tutorial
Guides
Database
SQL
Identifiers
Path Expressions
Data operators
Joins
Aggregates
Comparisons and Logical Operators
Sorting
Fetch
Offset Key
Indexes
Literals
Query Plan Hints
Reserved words
Query for Database Classes
SQL Isolation Between Applications
Transactions
Typed JSON
Blendable Web Apps
Network
Publishing Apps
Working with Starcounter
Cookbook
Powered By
GitBook
Joins
Introduction
Starcounter supports inner joins, cross joins, left outer joins and right outer joins.
The default join type is inner join, so if you use the reserved word
JOIN
, the parser will interpret it as an inner join.
Cross Join
A cross join is an inner join without join condition, and thus can be regarded as a special case rather than a separate type of join.
This query is interpreted as a cross join:
1
SELECT
e
,
d
FROM
Employee e
JOIN
Department d
Copied!
It can also be written as an explicit cross join:
1
SELECT
e
,
d
FROM
Employee e
CROSS
JOIN
Department d
Copied!
Inner Join
This query is interpreted as an inner join:
1
SELECT
e
,
d
FROM
Employee e
JOIN
Department d
ON
e
.
Department
=
d
Copied!
It can also be written as an explicit inner join:
1
SELECT
e
,
d
FROM
Employee e
INNER
JOIN
Department d
ON
e
.
Department
=
d
Copied!
Outer Joins
For left outer join and right outer join you may omit the reserved word
OUTER
.
This query returns all employees and their managers, including the employees that have no manager:
1
SELECT
e1
,
e2
FROM
Employee e1
LEFT
JOIN
Employee e2
ON
e1
.
Manager
=
e2
Copied!
This left outer join can also be written as a right outer join:
1
SELECT
e1
,
e2
FROM
Employee e2
RIGHT
JOIN
Employee e1
ON
e1
.
Manager
=
e2
Copied!
Previous
Data operators
Next
Aggregates
Last modified
4yr ago
Copy link
Contents
Introduction
Cross Join
Inner Join
Outer Joins