I\'m creating a java swing program where users can create a record, but I want to be able to check for duplicates before allowing the users to create the record. Here\'s my
If you want DutyName and volNric to have unique values, then do so with a unique constraint/index:
create index idx_assignrequests_dutyname_volnric on assignrequests(dutyname, volnric);
Then, when you do the insert, you can let it fail. Or, you can just ignore it using on duplicate key update:
INSERT into assignrequests(reqId, dutyName, volNric)"
VALUES ('" + id + "','" + dutyName + "','" + volNric + "')
ON DUPLICATE KEY UPDATE dutyName = VALUES(dutyName);
The column being updated is being set to itself -- so the operation doesn't do anything.