我正在使用Moodle数据库。我不希望在我的查询中显示任何NULL值。但到目前为止它还没有起作用:
SELECT mdl_user.department, mdl_user.id, mdl_user.username, mdl_user.firstname, mdl_user.lastname, mdl_course_completions.course, mdl_course_completions.timecompleted, mdl_course.fullname
FROM mdl_user LEFT JOIN (mdl_course_completions, mdl_course) ON (mdl_user.id = mdl_course_completions.id AND mdl_course_completions.id = mdl_course.id) WHERE NOT (mdl_course_completions.timecompleted IS NULL);\G
Empty set (0.00 sec)
我尝试使用IS NOT NULL,但这给了我相同的结果。
任何想法???
答案 0 :(得分:0)
这是我或多或少的期望:
<div id="store_map">
<div class="gm_popup">
<span class="address"> Address</span><br>
<span class="city"> City</span><br>
<span class="phone"> 123 456</span><br>
<span class="email"> email@example.com</span><br>
</div>
</div>
jQuery(document).ready(function(){
focus_and_popup = function (id){
//return_val = old_focus_and_popup (id);
jQuery("#store_map .gm_popup .email").click(function(){
var text = jQuery(this).text();
console.log("HERE");
document.location = "mailto:" + text.trim();
});
jQuery(".gm_popup .email").css('text-decoration','underline').css('color','#2aa8e0');
return return_val ;
}
focus_and_popup();
var old_focus_and_popup = focus_and_popup;
});
假设SELECT mdl_user.department, mdl_user.id, mdl_user.username,
mdl_user.firstname, mdl_user.lastname, mdl_course_completions.course,
mdl_course_completions.timecompleted, mdl_course.fullname
FROM mdl_user
LEFT JOIN mdl_course_completions ON mdl_user.id = mdl_course_completions.user_id
LEFT JOIN mdl_course ON mdl_course_completions.course_id = mdl_course.id)
WHERE mdl_course_completions.timecompleted IS NOT NULL
有外键mdl_course_completions
到user_id
和mdl_user(id)
到course_id
。
答案 1 :(得分:0)
SELECT
mdl_user.department,
mdl_user.id,
dl_user.username,
mdl_user.firstname,
mdl_user.lastname,
mdl_course_completions.course,
mdl_course_completions.timecompleted,
mdl_course.fullname
FROM mdl_user
LEFT JOIN (SELECT * FROM mdl_course_completions WHERE timecompleted IS NOT NULL) as mdl_course_completions
ON mdl_user.id = mdl_course_completions.user_id
LEFT JOIN mdl_course
ON mdl_course_completions.id = mdl_course.id
正如其他用户建议的那样,&#34; mdl_user.id = mdl_course_completions.id&#34;看起来并不正确&#34; user_id = user_id&#34;我假设mdl_course_completions的id不是用户的id?