Ohne getestet zu haben eventuell so:
PHP-Code:
Select from FileA a
where exists 
(Select from FileB B where a.key1 b.key1)
union all
Select 
from FileA c
where not exists 
(Select from FileB d where c.key1 d.key1)
union all
Select 
from FileB e
where not exists 
(Select from FileA f where e.key1 f.key1