无法使用select语句更新表中的行

时间:2012-07-12 10:03:02

标签: sql oracle

我在表中创建了一个列,我希望从该表中使用从另一个select语句中检索的数据填充该表。

这是我试图用来填充这一列的声明:

update cc_file
set sd_file_name = (select c1.name sd_file_name
                    from cc_file f, cvs3 c1 
                    where f.sd_file_id = c1.file_id 
                     and (c1.file_id, c1.type) in (select file_id, 
                                                          max(type) 
                                                   from cvs3 
                                                   where type1='PP' 
                                                     and type2='XHMTML' 
                                                   group by file_id)

当我在Oracle中运行此语句时,它显示此错误ORA-01427: single-row subquery returns more than one row

请有人让我知道如何做到这一点,以便更新专栏。

由于

1 个答案:

答案 0 :(得分:1)

试试这个

update cc_file 
  set xml_file_name = (select c1.name sd_file_name
                         from cvs3 c
                         where f.sd_file_id = cc_file.file_id and 
                               (c.file_id, c.type) in (select file_id, max(type)
                                                         from cvs3
                                                         where type1='PP' and 
                                                               type2='XHMTML'
                                                         group by file_id ))
相关问题