Reputation: 1246
I know that we can use the user()
and current_user()
function to get the currently logged in user. But I need just the user without the host-name suffixed. I cant seem to find any reference to built-in MySQL function that provides only the username.
Upvotes: 2
Views: 942
Reputation: 138
You can use the SUBSTRING_INDEX that basically returns the string before a character (in this case '@')
SELECT SUBSTRING_INDEX(current_user(),'@',1)
So basically with this you will avoid anything that is not the user part from current_user()
Upvotes: 3