Hier mal als expliziter Join
SQL-Code:
SELECT
distinct g.ID, g.Description
FROM
Groups g
join Templates t on t.GroupID = g.GroupID
WHERE
t.FormID = :FormId;
Alternativ wäre ein Gruppierung
SQL-Code:
SELECT
g.ID, g.Description
FROM
Groups g
join Templates t on t.GroupID = g.GroupID
WHERE
t.FormID = :FormId
grooup by
g.ID, g.Description;
oder ein Subselect denkbar:
SQL-Code:
SELECT
g.ID, g.Description
FROM
Groups g
where
g.GroupID in ( select distinct GroupID from Templates);
bzw.
SQL-Code:
SELECT
g.ID, g.Description
FROM
Groups g
where
exists ( select distinct t.GroupID from Templates where t.GroupId = g.GroupID);