この例を参照してください
CREATE TABLE book
(
bID INT,
bName VARCHAR(100),
PRIMARY KEY (bID)
);
--
CREATE TABLE author
(
aID INT,
aName VARCHAR(100),
PRIMARY KEY (aID)
);
CREATE TABLE book_author
(
aID INT ,
bID INT ,
PRIMARY KEY (aID,bID),
FOREIGN KEY (aID) REFERENCES author(aID),
FOREIGN KEY (bID) REFERENCES book(bID)
);
INSERT INTO author (aID, aName) VALUES
(1, 'The Doctor'),
(2, 'Dalek1'),
(3, 'Dalek2'),
(4, 'Amy'),
(5, 'Rory');
INSERT INTO book (bID, bName) VALUES
(1, 'The Book of Crazy'),
(2, 'Is Time Really Time'),
(3, 'I Think without Pants'),
(4, 'Perfection'),
(5, 'Rise of the Daleks ');
INSERT INTO book_author (aID, bID) VALUES
(4, 1),
(1, 2),
(4, 2),
(5, 2),
(1, 3),
(2, 4),
(2, 5),
(3, 5);
----------
--the query
SELECT DISTINCT b.bName
FROM book b,author a,book_author ba
WHERE ba.aID=a.aID and ba.bID=b.bID and (a.aName = 'Amy' or a.aName='The Doctor')
--------------
--output
--Is Time Really Time
--I Think without Pants
--The Book of Crazy
DISTINCT キーワードを使用し、Justin Wood の方法に従うだけです。