1

如果有人可以帮助我重写我的查询以在 mysql 5 中工作,我将非常感激。如果有人可以提供有关如何重写旧查询的可靠简单教程的链接,那也很棒。

我当前的(版本 4)查询如下所示:

SELECT
 course.course_code,
 course.course_title_sv AS course_title,
 course.course_u_credits,
 course.course_successive_level_scb_id,
 s.successive_level_scb_order,
 s.successive_level_scb_code,
 LEFT (education_level.edu_level_name_sv, 1) AS course_edu_level, course.course_level, 
 GROUP_CONCAT(DISTINCT h.head_area_hv_title_sv SEPARATOR ', ') AS head_area_hv
FROM
 course, course_event, course_event_package_links, package, education_level
LEFT JOIN
 course_has_head_area_hv ON(course.course_id = course_has_head_area_hv.course_id)
LEFT JOIN
 head_area_hv h ON(h.head_area_hv_id = course_has_head_area_hv.head_area_hv_id)
LEFT JOIN
 successive_level_scb s ON(s.successive_level_scb_id = course.course_successive_level_scb_id)
WHERE
 course.course_edu_level=education_level.edu_level_id AND
 course.course_id=course_event.course_id AND
 course_event.course_event_id=course_event_package_links.course_event_id AND
 course_event_package_links.package_id=package.package_id AND
 course.course_successive_level_scb_id != '' AND
 package.package_id='6318'
GROUP BY course.course_id
4

1 回答 1

0

只需更换

SELECT ... 
FROM course, course_event, course_event_package_links
...
WHERE course.course_id=course_event.course_id 
AND course_event.course_event_id=course_event_package_links.course_event_id

经过

SELECT ...
FROM course
JOIN course_event ON course_event.course_id = course.course_id
JOIN course_event_package_links 
  ON course_event_package_links.course_event_id = course_event.course_event_id
...

关于您的错误消息,您确定course.course_id存在吗?也许它被替换了course.course_code

于 2013-03-13T10:52:08.010 回答