2021-04-01 10:55题主

update无法修改数据

用 app.update({  tableName: 't_cmxx',  mode: 'update'});的方式修改记录,无法修改记录,在控制台跟踪SQL如下:
UPDATE t_cmxx 
SET 
    hbh = '1489',
    rbh = '1653',
    xm = '王XX',
    xb = '男',
    mz = '汉',
    xl = '大专',
    zjhm = '123456789012345678',
    sj = '12345678901',
    yhzgx = '户主',
    hb = '常住人口',
    hjdz = '区',
    zzmm = '群众',
    jkzk = '健康',
    khyh = '',
    yhkh = '',
    zhxgr = '管理员(admin)',
    zhxgsj = '2021-04-01 10:26:36',
    hGUID = '',
    xzyy = 'test',
    hyzk = '已婚',
    sfzqsrq = '',
    sfzyxq = ''
WHERE
    ('' IS NULL AND (hbh IS NULL OR hbh = '')        OR hbh = '')
        AND ('1653' IS NULL        AND (rbh IS NULL OR rbh = '')        OR rbh = '1653')
        AND ('王XX' IS NULL        AND (xm IS NULL OR xm = '')        OR xm = '王XX')
        AND ('男' IS NULL        AND (xb IS NULL OR xb = '')        OR xb = '男')
        AND ('汉' IS NULL        AND (mz IS NULL OR mz = '')        OR mz = '汉')
        AND ('大专' IS NULL        AND (xl IS NULL OR xl = '')        OR xl = '大专')
        AND ('123456789012345678' IS NULL        AND (zjhm IS NULL OR zjhm = '')        OR zjhm = '123456789012345678')
        AND ('12345678901' IS NULL        AND (sj IS NULL OR sj = '')        OR sj = '12345678901')
        AND ('户主' IS NULL        AND (yhzgx IS NULL OR yhzgx = '')        OR yhzgx = '户主')
        AND ('常住人口' IS NULL        AND (hb IS NULL OR hb = '')        OR hb = '常住人口')
        AND ('区' IS NULL        AND (hjdz IS NULL OR hjdz = '')        OR hjdz = '区')
        AND ('群众' IS NULL        AND (zzmm IS NULL OR zzmm = '')        OR zzmm = '群众')
        AND ('健康' IS NULL        AND (jkzk IS NULL OR jkzk = '')        OR jkzk = '健康')
        AND ('' IS NULL        AND (khyh IS NULL OR khyh = '')        OR khyh = '')
        AND ('' IS NULL        AND (yhkh IS NULL OR yhkh = '')        OR yhkh = '')
        AND ('管理员(admin)' IS NULL        AND (zhxgr IS NULL OR zhxgr = '')        OR zhxgr = '管理员(admin)')
        AND ('2021-03-29 03:00:00' IS NULL        AND (zhxgsj IS NULL OR zhxgsj = '')        OR zhxgsj = '2021-03-29 03:00:00')
        AND ('' IS NULL AND hGUID IS NULL        OR hGUID = '')
        AND ('test' IS NULL        AND (xzyy IS NULL OR xzyy = '')        OR xzyy = 'test')
        AND ('已婚' IS NULL    AND (hyzk IS NULL OR hyzk = '')      OR hyzk = '已婚')
        AND ('' IS NULL        AND (sfzyxq IS NULL OR sfzyxq = '')        OR sfzyxq = '')
每行第一个AND 后面都有个字段的值 IS NULL 的条件,但这样生成的SQL语句就没有满足的条件了。如何去掉这个条件?
注:我是用字典自动生成的字段,跟这个有关系吗?
2021-04-01 19:44#1
当前数据库记录中hbh是null值,第一个条件就不满足,后面全是and,查不到相关记录。
2021-04-01 19:47#2
自动生成where条件能不能手工指定其中几个字段,不要所有字段都生成条件?
2021-04-01 20:23#3

app.set("#hbh",data.hbh);   ---:data.hbh:传递的主键
app.update({  
tableName: 't_cmxx',  
mode: 'update',
whereFields:'hbh'
});
2021-04-02 09:30#4
棒!!!
2021-04-07 09:07#5
app.run(sql)也可以

返回开发者社区