26 lines
834 B
SQL
26 lines
834 B
SQL
WITH SystemConnections AS (
|
|
SELECT
|
|
ss_from.solarSystemId AS fromSystemId,
|
|
ss_to.solarSystemName AS toSystemName
|
|
FROM StarGates sg
|
|
JOIN SolarSystems ss_from ON sg.fromSystemId = ss_from.solarSystemId
|
|
JOIN SolarSystems ss_to ON sg.toSystemId = ss_to.solarSystemId
|
|
),
|
|
ConnectedSystems AS (
|
|
SELECT
|
|
fromSystemId,
|
|
GROUP_CONCAT(DISTINCT toSystemName) AS connectedSystems
|
|
FROM SystemConnections
|
|
GROUP BY fromSystemId
|
|
)
|
|
SELECT
|
|
ss.solarSystemName AS solarSystemName,
|
|
ml.x,
|
|
ml.y,
|
|
re.regionName as regionName,
|
|
COALESCE(cs.connectedSystems, '') AS connectedSystems
|
|
FROM MapLayout ml
|
|
JOIN SolarSystems ss ON ss.solarSystemId = ml.solarSystemId
|
|
JOIN MapLayouts mls ON ml.layoutId = mls.layoutId
|
|
JOIN Regions re ON re.regionId = mls.regionId
|
|
LEFT JOIN ConnectedSystems cs ON ss.solarSystemId = cs.fromSystemId; |