selectステートメントに問題があります。私がこれまでに持っているのはこれです-
SELECT COUNT(booked.desk_id),
name,
desk.desk_id,
phone,
fax,
dock,
pc
FROM desk, booked
WHERE desk.desk_id = booked.desk_id
AND booking_id >=1
AND location = "Cheltenham"
どの出力
"12" "Desk 1" "1" "1" "0" "0" "1"
これは私が欲しいものに近いですが、デスクテーブルにはデスク2と呼ばれる別のデスクがあります。これは完全に無視されています。実際、デスク2の予約がある場合は、デスク1のカウントとして表示されているものにそれらのカウントが含まれます...
テーブル全体の構造は次のとおりです。
table "booked"
INSERT INTO `booked` (`id`, `booking_id`, `desk_id`, `member_id`, `date_booked`) VALUES
(246, 1358121601, 1, 1, 'Monday 14th January at 4:40pm'),
(247, 1358121602, 1, 1, 'Monday 14th January at 4:40pm'),
(248, 1358121604, 1, 1, 'Monday 14th January at 4:40pm'),
(249, 1358121603, 1, 1, 'Monday 14th January at 4:40pm'),
(250, 1358121606, 1, 1, 'Monday 14th January at 4:40pm'),
(251, 1358121605, 1, 1, 'Monday 14th January at 4:40pm'),
(252, 1358121607, 2, 1, 'Monday 14th January at 4:40pm'),
(253, 1358121609, 2, 1, 'Monday 14th January at 4:40pm'),
(254, 1358121608, 2, 1, 'Monday 14th January at 4:40pm'),
(255, 1358121610, 2, 1, 'Monday 14th January at 4:40pm'),
(256, 1358121612, 2, 1, 'Monday 14th January at 4:40pm'),
(257, 1358121611, 2, 1, 'Monday 14th January at 4:40pm');
table "desk"
INSERT INTO `desk` (`location`, `desk_id`, `name`, `phone`, `fax`, `dock`, `pc`) VALUES
('Cheltenham', 1, 'Desk 1', 1, 0, 0, 1),
('Cheltenham', 2, 'Desk 2', 1, 1, 0, 1);
私が助けを必要としているのは、ステートメントを正しく構造化して、関連情報とともに各デスクの個々の行を出力する方法です。