example of how to use in MySQL

Should it be a function? And have a test? This is just an example, but one that works and I use in my code