码迷,mamicode.com
首页 > 数据库 > 详细

sybase update

时间:2014-09-13 03:00:04      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   strong   for   div   sp   

Using the wrong join condition in a FROM clause causes unpredictable results. If the FROM clause specifies a one-to-many join and the SET clause references a cell from the “many” side of the join, the cell is updated from the first value selected. In other words, if the join condition causes multiple rows of the table to be updated per row id, the first row returned becomes the update result. For example:

UPDATE T1 
SET T1.c2 = T2.c2
FROM T1 JOIN TO T2
ON T1.c1 = T2.c1

 

If table T2 has more than one row per T2.c1, results might be as follows:

T2.c1              T2.c2              T2.c3
1                  4                  3
1                  8                  1
1                  6                  4
1                  5                  2

With no ORDER BY clause, T1.c2 may be 4, 6, 8, or 9.

  • With ORDER BY T2.c3T1.c2 will be updated to 8.

  • With ORDER BY T2.c3 DESCT1.c2 will be updated to 6.

sybase update

标签:des   style   blog   color   io   strong   for   div   sp   

原文地址:http://www.cnblogs.com/peng-fei/p/3969411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!