空和非空值

时间:2012-12-19 11:55:11

标签: mysql sql select null

我希望通过比较u.fld_id = ct.fld_teacher_id来获取教师的信息 如果ct.fld_teacher_id为null,我将显示尚未分配。但是具有null ct.fld_teacher_id的行在执行时不会显示。

这是我的查询。

  SELECT ct.fld_id as id, ct.fld_serial, ct.fld_city, ct.fld_venue_name, 
        ct.fld_start_time, ct.fld_end_time, 
        ct.fld_duration, ct.fld_available_seats, 
        ct.fld_course_price, ct.fld_status,
        c.fld_name, u.fld_first_name, u.fld_last_name,
        ct.fld_status, ct.fld_teacher_id, ct.fld_training_name,
        ct.fld_class, ct.fld_level, ct.fld_is_fixed, tt.fld_name as training_type_name
   FROM tbl_course_training as ct, tbl_users as u,
        tbl_courses as c, tbl_training_types as tt
   WHERE c.fld_id = ct.fld_course_id AND u.fld_id = ct.fld_teacher_id AND 
       ct.fld_teacher_id = 'NULL' AND tt.fld_id = ct.fld_training_type_id 

0 个答案:

没有答案