Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8508177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:05:22+00:00 2026-06-11T03:05:22+00:00

I am having two tables student table it contains (Student_id,school_code,name,year,…) school table it contains

  • 0

I am having two tables

  1. student table it contains (Student_id,school_code,name,year,…)
  2. school table it contains (school_id,School_code,School_name,year
    etc…..)

I want to update the school_code column in the student table with the school_id column in the school code table based on school code and year. i m having five years data. so school_id varies for every year.

My query was

UPDATE Master.Student
   SET school_code=( select school_id from Master.school as sc
  JOIN master.student as st
    ON st.school_code=sc.school_code
 WHERE sc.year=x)
 WHERE st.year=x;

But its not updating. I am getting error of subquery returns more than one value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:05:23+00:00Added an answer on June 11, 2026 at 3:05 am

    Why to use sub-query when you can do that directly?

    UPDATE st
      SET st.school_code = sc.school_id 
    FROM master.student AS st
      JOIN Master.school AS sc
    ON st.school_code = sc.school_code
    WHERE sc.year=x
      AND st.year=x;
    

    For more info See UPDATE (Transact-SQL)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables as follows, Table name Payment_transaction having column name as payment_ref_id,
I'm having the following two tables... Table : room_type type_id type_name no_of_rooms max_guests rate
In MySQL Im having two tables: PRODUCTS (id, Name) SEEALSO (id, prodLeft, prodRight) SEEALSO
i'm having to two tables, which i need to compare both the table. Let
I have two tables as following table one named tbooking having column fields as
I have two tables having 1 to 1 relationship. One table called Person and
I am having two tables like this.Both are separate tables AccountNo User Name ----------------------------------
I having following two tables: reviews table: id visits table: id review_id I am
I'm having two tables table (fieldA, fieldB, fieldC) and log_table (id, fieldA, fieldB, fieldC).
I am having two tables Room_master and Room_Item Room_Master => roomid - pk, roomname

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.