Sembra un classico caso d'uso per EXISTS
operatore:
SELECT *
FROM mytable a
WHERE EXISTS (SELECT 1
FROM mytable b
WHERE a.foreignkey = b.foreignkey
AND trainer IS NOT NULL
AND trainer <> 'FREE'
MODIFICA:
Se desideri semplicemente la diversa foreignkey
s:
SELECT DISTINCT foreignkey
FROM mytable a
WHERE EXISTS (SELECT 1
FROM mytable b
WHERE a.foreignkey = b.foreignkey
AND trainer IS NOT NULL
AND trainer <> 'FREE'