ORA-01427: single-row subquery returns more than one row update…?? Help?

后端 未结 1 1837
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-22 02:56

My Query returns this error ORA-01427: single-row subquery returns more than one row update, This is my query

Update Table_b B
Set B.Material_Desc = (Select A.Ma         


        
相关标签:
1条回答
  • 2021-01-22 03:21

    The problem is your subquery is returning a whole bunch of rows where you should have only one. You can't do this like this.

    Depending on the SQL database you're using, something like this should work better :

    UPDATE Table_b B
    SET B.Materiel_Desc = A.Materiel_Desc
    INNER JOIN Table_a A ON A.PartNo = B.PartNo
    

    It is possible you must adapt the syntax to your database. For example, I think you cannot do it like this with MySQL. According to http://dev.mysql.com/doc/refman/5.0/en/update.html you should do :

    UPDATE Table_b, Table_A
    SET Table_b.Materiel_Desc = Table_A.Materiel_Desc
    WHERE Table_b.PartNo = Table_a.PartNo;
    
    0 讨论(0)
提交回复
热议问题