日期:2014-05-17  浏览次数:20705 次

同表更新问题,到底错在哪里?
update t1
  SET t1.QUERY_YN = t2.QUERY_YN,  
  t1.INSERT_YN = t2.INSERT_YN,  
  t1.DELETE_YN = t2.DELETE_YN,  
  t1.SAVE_YN = t2.SAVE_YN,  
  t1.PRINT_YN = t2.PRINT_YN,  
  t1.ETC_YN = t2.ETC_YN
  FROM TSECPERPROGRAM t1,TSECPERPROGRAM t2
  WHERE ( t1.LMENU_ID = t2.LMENU_ID ) and  
  ( t1.MMENU_ID = t2.MMENU_ID ) and  
  ( t1.PROGRAM_ID = t2.PROGRAM_ID ) and  
  (( t2.SNO = '111' and t1.SNO='222' ) ) ;  


这个语法不能更新成功,有什么错?

------解决方案--------------------
update t1 set ( , , ,...) = (select... from... where ...)
------解决方案--------------------
类似这样。
update IDS
set (NAMES,Names2)
= (select t2.NAMES,t2.Names2 from IDS t2 where id=101 and t2.id2=ids.id2 )
where id=102
------解决方案--------------------
同意1、3楼,楼主你语法错误。
------解决方案--------------------
update TSECPERPROGRAM t1
SET ( t1.QUERY_YN, 
t1.INSERT_YN, 
t1.DELETE_YN,
t1.SAVE_YN,
t1.PRINT_YN, 
t1.ETC_YN )= 
(select t2.QUERY_YN,
t2.INSERT_YN,
t2.DELETE_YN,
t2.SAVE_YN,
t2.PRINT_YN,
t2.ETC_YN
from TSECPERPROGRAM t2 
where t1.LMENU_ID = t2.LMENU_ID and
t1.MMENU_ID = t2.MMENU_ID and
t1.PROGRAM_ID = t2.PROGRAM_ID and
t2.SNO = '111 ' ) 
where t1.SNO= '222 ' );