Skip to content

Commit 2246011

Browse files
authored
Create update-using-select-via-join-sqlserver.sql
1 parent fd127a7 commit 2246011

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Method 2: Update via JOIN
2+
UPDATE Course
3+
SET is_active =
4+
CASE WHEN Department.code = 'EC' THEN 'Yes' ELSE 'No' END
5+
FROM Course
6+
JOIN Department ON Course.department_id = Department.id;
7+
8+
-- View result
9+
SELECT * FROM Course;

0 commit comments

Comments
 (0)