UPDATE IGNORE vn.dms SET dmsTypeFk = (SELECT id FROM vn.dmsType WHERE code = 'vehicle') WHERE id IN ( SELECT d.id FROM vn.dms d JOIN vn.dmsType dt ON dt.id = d.dmsTypeFk WHERE dt.code = 'vehicles' );