I think this example will help you. It is written in t-sql, but it should be easy to follow whatever platform you use.
CREATE TABLE Parent (
ParentId INT NOT NULL PRIMARY KEY
, ParentName VARCHAR(50) NOT NULL)
CREATE TABLE ChildA (
ChildAId INT NOT NULL PRIMARY KEY
, ParentId INT NOT NULL CONSTRAINT FK_ChildA_Parent FOREIGN KEY REFERENCES Parent(ParentId)
, ChildAName VARCHAR(50) NOT NULL)
CREATE TABLE ChildB (
ChildBId INT NOT NULL PRIMARY KEY
, ParentId INT NOT NULL CONSTRAINT FK_ChildB_Parent FOREIGN KEY REFERENCES Parent(ParentId)
, ChildBName VARCHAR(50) NOT NULL)
INSERT INTO Parent VALUES (1,'A')
INSERT INTO Parent VALUES (2,'B')
INSERT INTO Parent VALUES (3,'C')
INSERT INTO Parent VALUES (4,'D')
INSERT INTO ChildA VALUES (1,1,'a')
INSERT INTO ChildB VALUES (1,1,'a')
INSERT INTO ChildA VALUES (2,2,'b')
INSERT INTO ChildB VALUES (2,3,'c')
SELECT *
FROM Parent p
WHERE EXISTS (select 1 from ChildA a where p.ParentId = a.ParentId)
OR EXISTS (select 1 from ChildB b where p.ParentId = b.ParentId)
source
share