更新为null的列值 [英] update column values which are null

查看:151
本文介绍了更新为null的列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的sql数据库中有一列名为S-No。

其中包含以下数值:



S-No

____

1

____

2

____

Null

____

Null

____

3

____

Null

____

Null

____

Null

____

Null

____

Null

____

4

____

Null









现在,我想写这样的查询一种方式,S-No列包含1到2之间的Null,将值更新为1 .....并且在2到3之间有Null,将值更新为2 ......依此类推......例如。 3到4 - 更新为3,4到5 ---更新为4,5到6 ......我希望你会建议我查询..我不能写... :(我希望你的家伙会帮忙的。

I have one column in my sql database named as S-No.
Which has values like following :

S-No
____
1
____
2
____
Null
____
Null
____
3
____
Null
____
Null
____
Null
____
Null
____
Null
____
4
____
Null
.
.


Now, i want to write query in such a way that, which S-No column contains Null between 1 to 2, update there value to 1..... And which has Null between 2 To 3, update there value to 2... And so on... eg. 3 to 4 -- update as 3, 4 to 5 --- update as 4, 5 to 6...... I hope you will suggest me the query.. i am not able to write.. :( i hope you guyz will help.

推荐答案

看起来设计似乎不正确。首先要注意的是数据是无序的。另一件事是相关数据存储在一行中(如果它适用于单个实体),或者当数据传播到单独的实体时由引用连接。



我认为此时最好的建议是鼓励您了解第3范式(参见 http://en.wikipedia.org/wiki / Third_normal_form [ ^ ])



一种简单的方法是从 http:// www。 tutorialspoint.com/sql/sql-rdbms-concepts.htm [< a href =http://www.tutorialspoint.com/sql/sql-rdbms-concepts.htmtarget =_ blanktitle =New Window> ^ ]并查看数据库规范化。有一个教程将引导您完成第一,第二和第三范式。在我看来,这是你可能应该在你的情况下使用的。
It really seems that the design is incorrect. The first thing you must understand is that the data is in no order. Another thing is that related data is stored in a single row (if it applies to single entity) or is joined by a reference when the data is spread to separate entities.

I think that the best advice at this point is to encourage you to get to know 3rd normal form (see http://en.wikipedia.org/wiki/Third_normal_form[^])

One easy way is to start from http://www.tutorialspoint.com/sql/sql-rdbms-concepts.htm[^] and have a look at database normalization. There's a tutorial which wil guide you through first, second, and third normal forms. In my opinion this is what you probably should use in your situation.


这篇关于更新为null的列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆