当前位置: 代码迷 >> J2EE >> JAVA查询某个字段替空更新
  详细解决方案

JAVA查询某个字段替空更新

热度:94   发布时间:2016-04-22 02:49:53.0
JAVA查询某个字段为空更新
JAVA查询某个字段为空,返回个true或false,然后更新这个字段,怎么简化下,能不能放到一个SQL语句里
Java code
string str=null;String sql = ("select salesmanname from order where orderID = '"+033+"'");    sta.executeQuery(sql)try {    while(rs.next()) {        str = rs.getString(1);        }    if(str != null) {        isname = true;    //如果为空 返回true,反之返回false        return;    }    else {        isname = false        Strin sql = ("update order set salesmanname ='"+NewName+"' where orderID = '"+033+"'");                    sta.executeQuery(sql);    }} catch (Exception e) {    e.printStackTrace();} 


------解决方案--------------------
update 。。。。 where id=‘’ and salesmanname =''
------解决方案--------------------
update table set xx=? where id="22" and (salesmanname is null or salesmanname = '')
  相关解决方案