Results 1 to 5 of 5

Thread: Get certain characters

  1. #1
    Join Date
    May 2009
    Posts
    7

    Question Get certain characters

    How can I get only Phoenix from Phoenix, AZ?
    I have other cities and states on the query but in the same format.

    I've tried substr(a.air_location,-4,4) but I get ", AZ", the opposite of what I need.

    Thanks.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932

  3. #3
    Join Date
    May 2009
    Posts
    7
    I have other cities so the 7 might cut of other names..thanks for the input though.
    Last edited by antgaudi; 05-07-2009 at 03:43 PM. Reason: double name

  4. #4
    Join Date
    Apr 2009
    Posts
    86
    antgaudi, I don't know Oracle SQL functions and syntax but it should have this feature.

    Use a function to find the location in a string of a specified character. In your case, that would be a comma. This should return the number of the position of the comma (8 in the Phoenix, AZ example) in the text string. Embed this with a - 1 in the substring statement. Something like this:

    SUBSTR(A.AIR_LOCATION, 1, LOCATE(',', A.AIR_LOCATION) -1)

  5. #5
    Join Date
    May 2009
    Posts
    7
    I found something similar to that. Thanks.

Posting Permissions

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