根据身份证号查询年龄大于等于65岁的数据:

SELECT
       id,name,idcard,YEAR (NOW()) - substring(idcard, 7, 4) as age
FROM
students HAVING age >=65

根据身份证号查询年龄等于30岁的数据:

SELECT
       id,name,idcard,YEAR (NOW()) - substring(idcard, 7, 4) as age
FROM
students HAVING age = 30