I have table staff with columns id, code, surname, othernam es. I want to edit staff profile and save. The staff code is unique for all the staff. Note: I want to update the profile with old staff code or a new staff code that is not already in use by another staff.
I'm afraid you may have to clarify a little. I assume each row in the table is for a different staff member. I would also assume that each row "id" is unique. Is the "code" column another unique identifier? And am I right in saying that you are trying to generate a new unique "code" for a specific user?