-
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.
-
try
substr(a.air_location,1,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
-
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)
-
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
-
Forum Rules
|
|