fix SQL to support update mechanism