Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2013
    Posts
    5

    Unanswered: How to split column?

    I have a vendor_address1 column that contains this data: "1990 Westwood Blvd Ste 260"

    I have to move the "Ste 260" into another column named vendor_address2.
    How could I do that? SUBSTR maybe?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    "1990 Westwood Blvd Ste 260"
    how do you differentiate above from below?
    "107 Via De La Valle"
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2013
    Posts
    5
    Quote Originally Posted by anacedent View Post
    "1990 Westwood Blvd Ste 260"
    how do you differentiate above from below?
    "107 Via De La Valle"
    It dose not matter. I just have to move the "Ste 260" to different column only for this specific string, nothing else.

    So far I got this: REGEXP_SUBSTR(vendor_address1,'[^ ]+', 1, 4)

    But the problem with it is that I only get the "Ste"
    Last edited by Davy1992; 10-28-13 at 22:38. Reason: Progress

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    By far, the simplest solution is
    Code:
    update your_table set
      addr1 = '1990 Westwood Blvd',
      addr2 = 'Ste 260'
    where addr1 = '1990 Westwood Blvd Ste 260';
    Or, you can split the string in two as
    Code:
    with test as
      (select '1990 Westwood Blvd Ste 260' col from dual)
    select 
      substr(col, 1, instr(col, ' ', 1, 3) - 1)  addr1,
      substr(col, instr(col, ' ', 1, 3) + 1)     addr2
    from test
    or
    Code:
    with test as
      (select '1990 Westwood Blvd Ste 260' col from dual)
    select 
      rtrim(regexp_substr(col, '^(\w+ ){3}')) addr1,
      regexp_substr(col, '(\w+ \w+)$') addr2
    from test
    or any other option you find useful.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •