This is such a poorly designed, hacked together “thing” – it isn’t a database, it’s someone’s idea of how to store data when they don’t know how to store data, like they moved it from Access or Excel.
Just start over and design a proper relational schema with best practices and you’ll save, oh, perhaps 10 years of wasted effort and 12 million emails. This is as close to bandaids on bandaids on steroids that it comes. Really – rethink your solution model.
Mike
From: drum.lucas@gmail.com Sent: Tuesday, April 19, 2016 7:40 PM
Just forgot to say:
Does increment_client_code relate to users or some other table, say clients?
nope.. there is no link between them
If the users.code is empty/null, then the trigger has to get the last number from client_code_increment and put on the users.code column