一个表中有多个字段(不要扔臭鸡蛋呀),其中一个字段可能有多个空值,我现在想更新第一条值为空的记录该怎么写,表中有一个字段是自动递增的标识,其它都是无规律的。

解决方案 »

  1.   

    有标识就好办了咯,select top 1  * from table where 字段='' order by bs asc
      

  2.   

    update 表名 set 字段名 = '更新值'  where 标示字段=(select top 1 标示字段 from 表名 where 字段名 = '')
      

  3.   

    我给你个例子吧:
    update gree
    set password='123456'
    where  ID=(select top 1 ID from doctors where password='' {order by ID desc})
    这段话的意思是更改Gree表中密码为空的一个用户的密码为123456。ID是自动递增的标识。如果顺序相反就加一个逆向排序字串。也就是{}中的。
      

  4.   

    不好意思,更正一下:
    update gree
    set password='123456'
    where  ID=(select top 1 ID from gree where password='' {order by ID desc})
      

  5.   

    我再改:
    update gree
    set password='123456'
    where  ID=(select top 1 ID from gree where password is null {order by ID desc})
    这样总行了吧!!哈哈
      

  6.   

    update tablename set  FieldName = Value 
    where id= (select min(id) from tableName where FielDName is null)
      

  7.   

    其实应该把空格的值也加上去
    update gree
    set password='123456'
    where  ID=(select top 1 ID from gree where (password in (null,''))
    这样就清了!