Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos 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 support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > taking out the concatenated fields into one?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-04, 12:05
etravels etravels is offline
Registered User
 
Join Date: Feb 2004
Posts: 93
taking out the concatenated fields into one?

I have the following:



Address field which is concatenated.

3 The Manse||Tantany Lane





Now I want to select from the address field so I can break down the ‘address’ field into address1. address2, address3



Anyideas?


Select address??
__________________
Cheers
Etravels
Reply With Quote
  #2 (permalink)  
Old 09-30-04, 12:21
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
You will use INSTR and SUBSTR to parse the concatenated address. However, you will need to define some rules. For example, does address1 always end at the first space? If yes then:
Code:
select substr(address,1,instr(address,' ')-1) as address1
... and so on.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #3 (permalink)  
Old 09-30-04, 12:27
etravels etravels is offline
Registered User
 
Join Date: Feb 2004
Posts: 93
Red face thanx

first reply is yes
and how would I take out the address2 and address3 from the one address?
Also some addresses will be nULL values

Cheers
E
__________________
Cheers
Etravels
Reply With Quote
  #4 (permalink)  
Old 09-30-04, 12:30
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
What is address 1,2,3 for 3 The Manse||Tantany Lane?

Andrew makes a good point - how do you know where to break an address?
__________________
Oracle OCPI (Certified Practicing Idiot)
Reply With Quote
  #5 (permalink)  
Old 09-30-04, 12:50
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Quote:
Originally Posted by etravels
first reply is yes
and how would I take out the address2 and address3 from the one address?
Also some addresses will be nULL values
I've show how INSTR can be used to locate a delimiter string (e.g. ' ' or '||') in the address, and also how SUBSTR can be used to take out part of the address between delimiters. Getting address2 is similar to getting address1, except that you start after the first space, and go up to the '||' delimiter. You need to experiment with using these functions yourself.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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