I have these two tables:
tbl_courses
id user_id course_name
3 5 First Course
4 5 Second Course
tbl_notes
id user_id course_id
1 5 3
2 5 4
I am trying to write a simple merge script that is receiving an updated course title: course_name
For example, the user changed First Course to be Second Course and has requested that the all the notes with this new title be merged into this one.
So I am trying to find a way to update all the entries in tbl_notes with course_id from First Course to match the id of Second Course
I am sending $user_id, $course_id, and $course_name as parameters
If I correct understand there is query what you need:
SQLFiddleexample
With PHP code SQL query: