直接上代码
SELECT gu.id, gu.school_name, gu.student_no, gu.student_name, gu.id_card, gu.Job_category, gu.actual_employment_unit, gu.specialty, gu.phone, gu.affirm,
gu.labor_contract,gu.diploma, gu.household_file,gu.employment_certificate,
(SELECT guuu.update_content FROM `graduate_unit_update` guuu WHERE guuu.update_type=1 AND gu.`id`=guuu.graduate_unit_id ORDER BY guuu.create_time DESC LIMIT 1)
actualJobCategory,
(SELECT guu.update_content FROM `graduate_unit_update` guu WHERE guu.update_type=0 AND gu.`id`=guu.graduate_unit_id ORDER BY guu.create_time DESC LIMIT 1) effectiveUnit
FROM graduate_unit gu
WHERE gu.affirm=1
HAVING actualJobCategory IS NOT NULL OR effectiveUnit IS NOT NULL
总结:用 HAVING 即可实现
本文介绍了一种使用HAVING子句来筛选记录的SQL查询方法,通过示例代码展示了如何从已确认的数据中选择那些有过更新记录的单位信息。

被折叠的 条评论
为什么被折叠?



