Fixed sql query for order update