Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

How To get First,middle and last name from a column?

This is a discussion on How To get First,middle and last name from a column? within the Oracle forums, part of the Databases category; Hi friends, i have one problam,please give me the solution. I have column in a with name.now i want to select that names as first name,second name,third name. I/p---- names ...

Go Back   Geeks Talk > Databases > Oracle
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2008
Junior Member
 
Join Date: May 2008
Location: Bangalore
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
chandra.pc is on a distinguished road
How To get First,middle and last name from a column?

Hi friends, i have one problam,please give me the solution. I have column in a with name.now i want to select that names as first name,second name,third name. I/p---- names chandra sekhar balaji. Giri koti reddy nagendra lakshman bala now i want o/p like. Firstname secondname thirdname chandra sekhar balaji giri koti reddy nagendra lakshman bala
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-24-2008
Expert Member
 
Join Date: Sep 2007
Posts: 738
Thanks: 22
Thanked 67 Times in 65 Posts
krishnaindia2007 is on a distinguished road
Re: How To get First,middle and last name from a column?

Here is the query

SQL> SELECT substr(name,1,instr(name,' ',1,1)-1) Firstname,
substr(name,instr(name,' ',1,1)+1,(instr(name,' ',1,2)-instr(name,' ',1,1))-1) Middlename,
substr(name,instr(name,' ',1,2)+1) Lastname
FROM test;

FIRSTNAME MIDDLENAME LASTNAME
------------------------------ ------------------------------ ------------------------------
chandra sekhar balaji
Giri koti reddy
nagendra lakshman bala

SQL>
Reply With Quote
The Following User Says Thank You to krishnaindia2007 For This Useful Post:
  #3 (permalink)  
Old 05-27-2008
Junior Member
 
Join Date: May 2008
Location: mumbai
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
satishorre is on a distinguished road
Re: How To get First,middle and last name from a column?

Select substr('giri koti reddy nagendra lakshman bala',1, instr('giri koti reddy nagendra lakshman bala',' ',1)) first_name, substr('giri koti reddy nagendra lakshman bala',instr('giri koti reddy nagendra lakshman bala',' ',1)+1, instr('giri koti reddy nagendra lakshman bala',' ',2)) middle_name, substr('giri koti reddy nagendra lakshman bala',instr('giri koti reddy nagendra lakshman bala',' ',-2)+1, instr('giri koti reddy nagendra lakshman bala',' ',-1)) last_name from dual
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Insert new column in the middle of a table Geek_Guest SQL 20 12-06-2008 11:23 AM
Inserting column in the middle mohdfarezpink SQL 2 01-23-2008 05:57 AM
Column to row transformation JobHelper Data Warehousing 2 01-18-2008 08:27 AM
Row to Column cme_prak Data Warehousing 3 01-16-2008 01:56 AM
Middle node ptr of a linked list Geek_Guest C and C++ 1 07-31-2007 01:52 AM


All times are GMT -4. The time now is 11:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved