Skip to main content

Posts

Showing posts with the label instr

How to separate string from email id in SQL

To separate string from email id in SQL you can try below query. seperate ' test' '@' 'xyz'   ' com'   from test@xyz.com SELECT SUBSTR(mailID, 1, INSTR(mailID, '@', 1, 1)-1) String1, SUBSTR(mailID, INSTR(mailID, '@', 1, 1), 1) String2, SUBSTR(mailID, INSTR(mailID, '@', 1, 1)+1, INSTR(mailID, '.', 1, 1)-INSTR(mailID, '@', 1, 1)-1) String3, SUBSTR(mailID, INSTR(mailID, '.', 1, 1)+1) String4 FROM ( SELECT '&MailID' mailID FROM Dual );

How to get middle name from full name column in SQL Table

The question is How get middle name from full name column in SQL Table? Full name can be like this. Santosh kumar singh Raj Narayan verma Middle name is Kumar and Narayan etc. Solution. Use instr to get the position of first space and second space.use substr to get the string from first space +1 to 2nd space - 1. I hope you will get solution. Example.  Using substr function it will get the result of middle names. Substr(colname,instr(colname, ' ', 1,1),instr(colname,' ' , -1,1))