One of the checkout records is incorrect. It turns out, the student with id 4 ne
ID: 3596810 • Letter: O
Question
One of the checkout records is incorrect. It turns out, the student with id 4 never checked out the book with id 1. He checked out the book with id 2. Write a SQL statement that Updates the information in book_checkout relation.
book bookid title Introduction of Algorithms rice total copies 84.66 Database System Concepts74.99 Stochastic Calculus for Financ41.02 Stochastic Calculus for Finance II 55.22 course title Algorithms DB Organization Advanced DB Organization Math Finance I Math Finance II faculty enroll studentid courseid student studentid facultyid name gpa Tom 3.3 John3.8 Mary 3.0 Kris 3.6 Alex3.5 James 70000 Sarah 60000 ay 80000 Rache 70000 Pau85000 book_ checkout bookid studentid 2017-08-29 2017-09-02 2017-09-07Explanation / Answer
update book_checkout set bookid=2 where studentid=4 and bookid=1;
This query will update the bookid to 2 which is having studentid 4. Here we also checking the condition bookid=1 also because in this table we also having another book checkout with bookid 4 for the same studentid having 4. so to update the bookid from 1 to 2 we are checking bookid and studentid.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.