I have a special scenario to update my department without having any conflicts with the existing records.
Can someone tell me how to write a query for it?
Here is my need.
Table Dept
:
DeptID DeptName
-----------------------------
D001 Accounts
D002 HR
D003 Dev
D004 Support
Now, I want to update one of the existing records and make sure that it should not allow duplicates (Either deptid
or deptname
and both).
Ex:
Case 1: When I try to update
D001
, I should not giveDeptID
like D002, D003 or D004 as they are already existing.Case 2: When I try to edit
DeptName
, it should not accept any of the existing DeptNames