0
我在MySQL 5.5.3下執行這個查詢時遇到了一些問題。它返回查詢錯誤(1066):不是唯一的表/別名:「類」查詢錯誤(1066) - MySQL
SELECT COUNT(DISTINCT lra.userid) AS learners, COUNT(DISTINCT tra.userid) AS teachers
FROM mdl_course AS courses, mdl_course_categories AS categories
LEFT JOIN mdl_context AS ctx ON c.id = ctx.instanceid
JOIN mdl_role_assignments AS lra ON lra.contextid = ctx.id
JOIN mdl_role_assignments AS tra ON tra.contextid = ctx.id
JOIN mdl_course_categories AS categories ON courses.category = categories.id
WHERE courses.category = categories.id
AND (
categories.path LIKE '%/9/%'
OR categories.path LIKE '%/9'
)
AND lra.roleid=5
AND tra.roleid=3
我在一個小的損失的是我已經使用了別名列以及表名。任何人都可以發現我可能出錯的地方嗎?
十分感謝!我知道這對我來說會很愚蠢!只要我被允許,我會盡快接受。 – 2014-09-24 11:03:20
非常歡迎。 – 2014-09-24 11:06:57