Home » SQL & PL/SQL » SQL & PL/SQL » Strings
Strings [message #242] Thu, 31 January 2002 13:01 Go to next message
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 Go to previous messageGo to next message
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
Re: Strings [message #281 is a reply to message #242] Sun, 03 February 2002 17:53 Go to previous message
Abul Fazal
Messages: 39
Registered: February 2002
Member
Select translate(Name, ' ', ',')
from
Previous Topic: Two Selects ..... How?
Next Topic: Query for table spaces
Goto Forum:
  


Current Time: Fri Mar 29 06:43:28 CDT 2024