I am trying to extract the left part of an email field based on the separator @.
For instance, from the following email: root@localhost I want to extract root.
I wrote:
select email, substr(email,1,strpos(email, '@')-1)
from user;
but I get:
[22011] ERROR: negative substring length not allowed
How can I make the substring inside a function?