非常に複雑なクエリを作成していますが、複雑であるかどうかはわかりませんが、データベースエラーが発生しましたエラー番号:1066ユニークでないテーブル/エイリアス:
エラーメッセージ:1066ないユニークなテーブル/別名: 'BB'
SELECT cl.*,
(CASE
WHEN id_student IS NOT NULL THEN 'BOOKED' ELSE
(
CASE
WHEN (max_count - student_count) > 0 THEN 'AVAILABLE' ELSE 'FULL'
END
)
END) AS course_status
FROM (
SELECT aa.*, bb.id_student, cc.max_count, dd.student_count
FROM (
SELECT c.id_course, c.id_study, c.id_level, c.id_teacher, c.course_date,
s.study_name,
t.teacher_name,
t.teacher_picture
FROM tbl_course c
LEFT JOIN tbl_study s ON s.id_study = c.id_study
LEFT JOIN tbl_teacher t ON t.id_teacher = c.id_teacher
WHERE
CONCAT('"', REPLACE(c.id_level, ',', '","'), '"') LIKE '%"64"%'
AND c.id_study = '2'
AND c.course_date
AND c.id_study = '2'AND c.course_date
BETWEEN "2016-10-02 00:00:00" AND "2016-10-09 23:59:59" ORDER BY c.course_date ASC
) aa
LEFT JOIN (
SELECT id_student, id_course
FROM tbl_course_student
WHERE id_student = '305'
AND id_study = '2'
) bb ON aa.id_course = bb.id_course
LEFT JOIN (
SELECT SUM(student_count_max) AS max_count, course_date
FROM tbl_course
WHERE id_study = '2'
AND course_date BETWEEN "2016-10-02 00:00:00" AND "2016-10-09 23:59:59"
AND id_study = '2') bb ON bb.id_course = aa.id_course
LEFT JOIN (
SELECT SUM(student_count_max) AS max_count, course_date
FROM tbl_course
WHERE id_study = '2'AND course_date BETWEEN "2016-10-02 00:00:00" AND "2016-10-09 23:59:59"
AND CONCAT('"', REPLACE(id_level, ',', '","'), '"') LIKE '%"64"%'
GROUP BY course_date, id_study
) cc ON aa.course_date = cc.course_date
LEFT JOIN (
SELECT SUM(student_count) AS student_count, course_date
FROM tbl_course
WHERE id_study = '2'
AND course_date BETWEEN "2016-10-02 00:00:00" AND "2016-10-09 23:59:59"
AND CONCAT('"', REPLACE(id_level, ',', '","'), '"') LIKE '%"64"%'
AND course_date BETWEEN "2016-10-02 00:00:00" AND "2016-10-09 23:59:59" AND CONCAT('"', REPLACE(id_level, ',', '","'), '"') LIKE '%"64"%'
GROUP BY course_date, id_study
) dd ON aa.course_date = dd.course_date
) cl
GROUP BY course_date, course_status
私の質問:データベースエラーが エラー番号を発生しました
WHE私は間違っていましたか?私はこれらの質問を何度も読んできましたが、何も見つかりませんでした。
ありがとう、私はまだそれを動作させるために修正する必要があります –