In Salesforce Apex, use the merge DML operation to combine up to three records, designating one as the master while deleting duplicates. Syntax is:
apex
merge masterRecord duplicateRecords;
The master record’s values are retained in conflicts, but fields can be adjusted before merging. Use try-catch blocks for error handling. Merge limits apply (three records per operation), and permissions are required. Triggers can automate merging based on criteria, like matching emails, making it useful for deduplication.