如楼上所说,用IF做几个分支就行了。

解决方案 »

  1.   

    if判断一下几种情况就可以了。
      

  2.   

    declare @sql varchar(100);
    set @sql = 'update user set ';
    if(PUserName is not null) then
    @sql = concat(@sql, 'username = "test"');
    end if;
    if(PReMark is not null) then
    @sql = concat(@sql, ',Re = 'TestRe'');
    end if;
    @sql = concat(@sql, ' where userid = 1');
    prepare s from @sql;
    execute s;
    deallocate prepare s;