All pastes #110244 Raw Edit

Something

public text v1 · immutable
·published 2006-08-01 14:04 UTC
rendered paste body
SELECT C.name AS category,
       E.name AS port
 FROM element E, categories C, ports P
    JOIN (SELECT DISTINCT from_port_id as port_id
            FROM ports_moved UNION
SELECT DISTINCT to_port_id as port_id
            FROM ports_moved ) as tmp on P.id = tmp.port_id
           WHERE E.id = P.element_id
             AND C.id = P.category_id
        ORDER BY 1, 2