I'm new to MySQL, so this may be a dumb question, but I haven't found an answer specificly after googling and digging here on SO.
All I'm attempting to do is get the user ID, and only the user ID, of the invoking user of an insert or update on a given table. I'm not asking for any help with a trigger in this question, so don't worry about that.
SELECT user()
Gives: user@[IP Address]
SELECT current_user()
Gives: user@%
Minor problem: I only want user
My Question:
Am I going about this the wrong way?
Is there a cleaner, or more readable way to get just user
rather than having to use something likesubstr(user(),1,instr(user(),'@')-1)
? I've written some triggers in Oracle where I could just use the USER
value for what I need.
Thanks in advance
Manual page says:
SELECT SUBSTRING_INDEX(USER(),'@',1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With