Update更新时where条件后面使用rownum=1
update tmp_168_month t37
set (t37.acc_mode, t37.dp_id, t37.dp_code, t37.accessid)
= (select tf.ACC_MODE, tf.onuid, tf.onucode, tf.accessid
from tmp_168_month_fttx tf
where t37.serv_id=tf.serv_id and rownum=1)
where exists(select 1 from tmp_168_month_fttx tf
where t37.serv_id=tf.serv_id)
and t37.acc_mode is null;
对于这个更新语句,为什么要加一个rownum=1的限制呢?如果把它去掉,如下:
update tmp_168_month t37
set (t37.acc_mode, t37.dp_id, t37.dp_code, t37.accessid)
= (select tf.ACC_MODE, tf.onuid, tf.onucode, tf.accessid
from tmp_168_month_fttx tf
where t37.serv_id=tf.serv_id)
where exists(select 1 from tmp_168_month_fttx tf
where t37.serv_id=tf.serv_id)
and t37.acc_mode is null;
两者会有什么区别吗??