Sql Query Language using subquery [closed]











up vote
-5
down vote

favorite












How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?



Here is the schema of the database:



Attached is the schema of the database










share|improve this question









New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Great idea, just do it. But 1 million times would be even better ;-)
    – dnoeth
    Nov 10 at 16:21

















up vote
-5
down vote

favorite












How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?



Here is the schema of the database:



Attached is the schema of the database










share|improve this question









New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Great idea, just do it. But 1 million times would be even better ;-)
    – dnoeth
    Nov 10 at 16:21















up vote
-5
down vote

favorite









up vote
-5
down vote

favorite











How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?



Here is the schema of the database:



Attached is the schema of the database










share|improve this question









New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?



Here is the schema of the database:



Attached is the schema of the database







sql






share|improve this question









New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 11 at 4:43





















New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 16:18









Fred Adrah

32




32




New contributor




Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Fred Adrah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Great idea, just do it. But 1 million times would be even better ;-)
    – dnoeth
    Nov 10 at 16:21
















  • 1




    Great idea, just do it. But 1 million times would be even better ;-)
    – dnoeth
    Nov 10 at 16:21










1




1




Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21






Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21














1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Query:



UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    Query:



    UPDATE instructor
    SET salary = 10000 *
    (SELECT COUNT(*) FROM section s
    JOIN teaches t ON s.sec_id = t.sec_id
    JOIN instructor i ON t.id = i.id
    WHERE i.id = instructor.id);





    share|improve this answer

























      up vote
      0
      down vote



      accepted










      Query:



      UPDATE instructor
      SET salary = 10000 *
      (SELECT COUNT(*) FROM section s
      JOIN teaches t ON s.sec_id = t.sec_id
      JOIN instructor i ON t.id = i.id
      WHERE i.id = instructor.id);





      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Query:



        UPDATE instructor
        SET salary = 10000 *
        (SELECT COUNT(*) FROM section s
        JOIN teaches t ON s.sec_id = t.sec_id
        JOIN instructor i ON t.id = i.id
        WHERE i.id = instructor.id);





        share|improve this answer












        Query:



        UPDATE instructor
        SET salary = 10000 *
        (SELECT COUNT(*) FROM section s
        JOIN teaches t ON s.sec_id = t.sec_id
        JOIN instructor i ON t.id = i.id
        WHERE i.id = instructor.id);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 17:43









        Antonio Alvarez

        10214




        10214















            Popular posts from this blog

            Florida Star v. B. J. F.

            Error while running script in elastic search , gateway timeout

            Adding quotations to stringified JSON object values