Thread: Update Error

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Update Error


    Hello,
    I am trying to update a column based on another column in the same table (student table) and a column
    from another table (school table)

    Code is:

    update student_table
    set student_code =
    (select l.student_code
    from school_table l, student_table n
    where l.school = n.schoolname)

    I get the following error

    ORA - 01427 Single-row subquery returns more than one row

    Any help would be appreciated.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    844
    Rep Power
    387

    Cool


    1) You do not need to repeat the table you are updating (student_table) in the join with the school_table.

    2) You query from the school table is returning multiple rows, you need to make it return a single row per student.


IMN logo majestic logo threadwatch logo seochat tools logo