SQL Query - Extract Middle name
690375Mar 11 2009 — edited Mar 11 2009I am still in training and have a scenario where I need to extract the middle name ONLY out of a table 'EMP'. Using Toad I have currently gotten this far:
bq. SELECT SUBSTR(ENAME,1,INSTR(ENAME,' ',1,1)-1)FIRSTNAME, \\ SUBSTR(ENAME,INSTR(ENAME,' ',1,1)+1),(INSTR(ENAME,' ',1,2)-INSTR(ENAME,' ', 1,1)-1)MIDDLENAME, \\ SUBSTR(ENAME,INSTR(ENAME,' ',1,2)+1)LASTNAME \\ FROM EMP;
The data is in the following format:
bq. 'John William Edwards'
Can some one please help me with this? If possible I would like an explanation as well so I can understand.
Thanks!
Edited by: javeriac@gmail.com on Mar 11, 2009 9:49 AM