これを試して:
SELECT b.bookname, m.mname
FROM (transaction AS t
LEFT JOIN books AS b
ON b.bookid = t.bookid)
LEFT JOIN member AS m
ON m.mid = t.mid
WHERE t.ttype='issue';
サンプルデータ:
CREATE TABLE books(
bookid INT AUTO_INCREMENT PRIMARY KEY,
bookname VARCHAR (50)
);
CREATE TABLE member(
mid INT AUTO_INCREMENT PRIMARY KEY,
mname VARCHAR (30)
);
CREATE TABLE transaction(
transid INT AUTO_INCREMENT PRIMARY KEY,
bookid INT,
mid INT,
ttype VARCHAR (10),
issue_dt DATETIME,
due_dt DATETIME,
transremark varchar(200)
);
INSERT INTO books(bookname)
VALUES ("Harry Potter and the Philosopher's Stone"), ("Harry Potter and the Chamber of Secrets"), ("Harry Potter and the Prisoner of Azkaban");
INSERT INTO member(mname)
VALUES ('bob'), ('jack'), ('joe');
INSERT INTO transaction(bookid,mid,ttype,issue_dt,due_dt,transremark)
VALUES (1,1,'issue', curdate(),curdate()+ INTERVAL 5 DAY, "UPS"),
(1,2,'issue', curdate(),curdate()+ INTERVAL 5 DAY, "UPS"),
(3,1,'issue', curdate(),curdate()+ INTERVAL 5 DAY, "UPS"),
(2,1,'issue', curdate(),curdate()+ INTERVAL 20 DAY, "UPS"),
(3,3,'no_issue', curdate(),curdate()+ INTERVAL 20 DAY, "FEDEX");
http://sqlfiddle.com/#!2/91b0d/5
編集:制限あり
SELECT b.bookname, m.mname
FROM (transaction AS t
LEFT JOIN books AS b
ON b.bookid = t.bookid)
LEFT JOIN member AS m
ON m.mid = t.mid
WHERE t.ttype='issue'
LIMIT 1 offset 3;
http://sqlfiddle.com/#!2/91b0d/7
聞き間違いかもしれませんが、本名と会員名のみでお願いします。さらに情報が必要な場合は、このクエリも使用できます。上記の現在のクエリで SELECT * FROM を置き換えます。
プロジェクトをよろしくお願いします。