I know that we can use the user()
and current_user()
functions to get the currently logged in user. But I only need users without hostname suffix. I can't seem to find any reference to the built-in MySQL function that just provides a username.
P粉9663356692024-03-28 00:43:39
You can use SUBSTRING_INDEX to return the string before the character (in this case "@")
SELECT SUBSTRING_INDEX(current_user(),'@',1)
So basically this way you avoid anything that is not the user part of current_user()