update table s set s.status=0 where not exists (select max(sms.id) mid,phone from table sms group by sms.phone having max(sms.id)=s.id)