Strings [message #242] |
Thu, 31 January 2002 13:01  |
kmsav
Messages: 3 Registered: January 2002
|
Junior Member |
|
|
I need to take a name field and throw a comma in between the name
example
Name: John Doe
when I query it should come out Doe, John. I believe I need to use a substr/instr function, but I am not sure how to use it.
|
|
|
Re: Strings [message #245 is a reply to message #242] |
Thu, 31 January 2002 18:06   |
Diwakar Bhandari
Messages: 7 Registered: January 2002
|
Junior Member |
|
|
Hi ,
Lemme show u how to do it ... I'm using an employee table with 3 columns ...id, last_name , deptno .
SQL> insert into employee values(9000,'John Doe' ,20);
1 row created.
SQL>select (substr(last_name,instr(last_name,' ') )||', '||substr(last_name,1,instr(last_name,' ') ))as Name from employee where id = 9000;
NAME
----------------------
Doe, John
Hope this helps !!!!
Regards ,
Diwakar
|
|
|
|