美文网首页iOS Developer
sql 查询结果if else

sql 查询结果if else

作者: HT_Jonson | 来源:发表于2017-03-03 09:31 被阅读0次

    SELECT
    s.time AS TIME,
    'tts投诉' AS sugesstWall,
    r.region_name AS courseName,
    c.center_name AS centerName,
    cr.class_name AS className,
    tscc.course_name AS courseName,
    stu.true_name AS studentName,
    stu.phone AS studentPhone,
    CASE s.flag
    WHEN 0 THEN '投诉'
    WHEN 1 THEN '建议'
    ELSE '表扬'
    END AS flag ,
    st.type_name AS type_name,
    s.obj_name AS obj_name,
    dep.dept_name AS deptName,
    tel.name AS titleName,
    s.content AS content
    FROM
    suggest s
    LEFT JOIN center c ON c.center_id = s.center_id
    LEFT JOIN city ON city.city_id=c.city_id
    LEFT JOIN region r ON city.region_id=r.region_id
    LEFT JOIN suggest_type st ON st.type_id = s.suggest_type
    LEFT JOIN student stu ON s.student_id=stu.student_id
    LEFT JOIN classroom cr ON stu.class_id=cr.class_id
    LEFT JOIN series_class sc ON sc.series_class_id = cr.series_class_id
    LEFT JOIN tsc_course tscc ON sc.course_id = tscc.course_id
    LEFT JOIN employee e ON e.employee_id=s.obj_id
    LEFT JOIN dept dep ON e.dept_id=dep.dept_id
    LEFT JOIN title tel ON tel.title_id=e.title_id
    WHERE 1=1
    AND s.time >= '2016-09-01 00:00:00'
    AND s.time < '2016-10-01 00:00:00'

    相关文章

      网友评论

        本文标题:sql 查询结果if else

        本文链接:https://www.haomeiwen.com/subject/jmslgttx.html