mysql 关联左表不存在数据 并 根据身份证计算查找大于65岁以上老人
---
//查找左边不存在数据,不能用 = '' SELECT m.uid FROM es_members m LEFT JOIN es_user_self_care_assessment u ON m.uid = u.user_id WHERE u.user_id IS NULL //合并起来查找 #(YEAR (NOW()) - substring(m.idcard, 7, 4)) as n 计算出年龄 SELECT m.uid,(YEAR (NOW()) - substring(m.idcard, 7, 4)) as n FROM es_members m LEFT JOIN es_user_self_care_assessment u ON m.uid = u.user_id WHERE m.idcard >0 and u.user_id IS NULL HAVING n>65