update m_label set leaf =1 from (select t.id as mid from m_label t where NOT EXISTS (select distinct(b.parent_id) as id from m_label b where t.id=b.parent_id)) as tb where id = tb.mid
update m_label set leaf =1 from (select t.id as mid from m_label t where NOT EXISTS (select distinct(b.parent_id) as id from m_label b where t.id=b.parent_id)) as tb where id = tb.mid