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

  • Home
  • SEARCH
  • 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 8582425
In Process

The Archive Base Latest Questions

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

I have the following problem: I am trying to add every student in the

  • 0

I have the following problem:

I am trying to add every student in the Comp. Sci. department into a course, here are the DDL for the relations:

The desired course has values of (‘CS-001’, ‘Weekly Seminar’, ‘Comp. Sci.’, 0)


Department 
      (dept_name [primary key], building, budget)

Course 
      (course_id [primary key], title, dept_name, credits)

Instructor 
      (ID [primary key], name, dept_name, salary) 
      Foreign Key is dept_name references Department

Section
      (course_id [primary key], sec_id [primary key], semester [primary key], year [primary key], building, room_number, time_slot_id) 
      Foreign Key course_id references Course

Teaches 
      ( ID [primary key], course_id [primary key], sec_id [primary key], semester [primary key], year [primary key]) 
       Foreign key ID references Instructor,
Foreign Key (course_id,sec_id,semester,year) references Section

Takes 
      (ID [primary key], course_id [primary key], sec_id [primary key], semester [primary key], year [primary key], grade) 
      Foreign key(course_id,sec_id,semester,year) references section Foreign key(ID) references student

Student 
      (ID [primary key], name, dept_name, tot_cred) Foreign key(dept_name) references department

The problem is that I’m getting an error when trying to use an update statement (Error is 1241 Operand should have 1 column), correct my syntax as it is more than likely the problem:

update takes
set ID=ID, course_id='CS-001', sec_id='1', semester='Fall', year=2009, grade=null
where
(
select distinct name, ID
from student natural join takes
where dept_name='Comp. Sci.'
);

Sorry I’m new at MySQL, if you could just guide me to correcting my syntax and possibly a better solution than mine (not sure if mine is even a solution).

  • 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-11T21:17:24+00:00Added an answer on June 11, 2026 at 9:17 pm

    You have not specified a column in you WHERE clause that’s is why you are getting Error 1241 Operand should contain 1 column(s)

    update takes
    set ID=ID, course_id='CS-001', sec_id='1', semester='Fall', year=2009, grade=null
    where
    (
       select distinct name, ID
       from student natural join takes
       where dept_name='Comp. Sci.'
    );
    

    Alternatively, join both tables

    UPDATE  takes a 
            INNER JOIN student b
                ON a.ID = b.ID 
    SET     a.ID = ID, 
            a.course_id='CS-001', 
            a.sec_id='1', 
            a.semester='Fall', 
            a.`year` = 2009, 
            a.grade = 0        -- you can't set NULL value when updating a column
    WHERE   b.dept_name = 'Comp. Sci.'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem. I'm trying to add a timer job following this
I'm a newbie in bash scripts and have the following problem : I'm trying
Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I am trying to solve the following problem with Puppet: I have multiple nodes.
I'm trying to solve the following problem in Redis. I have a list that
I am trying to solve the following problem. Lets say you have the the
I have the following code, The problem is when I'm trying to assign the
I have a bit of a problem. I am trying to do the following
Hi I have the following problem and I am trying to work out what
I have the following problem trying to use a custom config section in my

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.