I have tables as below:
Language
language_id | language_name
--------------------
1 English
2 Hindi
Book
book_id | language_id | book_name
---------------------------------
1 1 Head First Java
2 1 Head First C
3 2 Head First Java
4 2 Head First C
Student
student_id | language_id | book_id
--------------------------------------
1 1 1
2 2 3
Now, I have to update the book_id column of Student table, with id value of another book where the current book_name = Head First Java, new book_name = Head First C and the new book must be of same language.
Sample Result:
student_id | language_id | book_id
--------------------------------------
1 1 2
2 2 4
I am facing issues to write a T-SQL query to do this. Please help me on this.
UPDATE-Statement in SQL-Server?