Files
stinkinator/backend/selectAssociation.sql

28 lines
516 B
SQL

-- 3. Get all associations (N rows)
with
AllAssociations as (
select
lhs as PlayerID,
rhs as AssociateID,
note
from
association
where
lhs = $1
union
select
rhs as PlayerID,
lhs as AssociateID,
note
from
association
where
rhs = $1
)
select
p.id as AssociateID,
p.name as AssociateName,
coalesce(a.note, '') as AssociationNote
from
AllAssociations a
join player p on a.AssociateID = p.id;