Skip to main content
Inspiring
September 26, 2008
Question

How can I possibly get the state out?

  • September 26, 2008
  • 2 replies
  • 494 views
I'm facing with a strange records.
I need to get the state information out from 4 column NameAddresses.
Here is the scenario:
Column NameAdd1 is populated with records like:
1234 Smith Avenue TX 77581-5021,
3625 Cricket Creek DR,
555 RALPH MCGILL BLVD NE (NE is not Nebraska, NE stands for North East)

Column NameAdd2:
blank, >>>> because the State information for this person has been placed in NameAdd1 TX 77581-5021
DELTONA FL 32725, >>> this is the continuation from 3625 Cricket Creek Dr address on NameAdd1
RIO RANCHO NM 87144 >>is a continuation from 555 RALPH MCGILL BLVD NE

Column NameAdd3 :
blank,
blank,
blank,
MILWAUKEE WI 53202,
16 Pueblo Drive

Column NameAdd4:
blank,
blank,
blank,
blank,
Alhambra CA 91207

So, when Column NameAdd1 has contain State abbriviation and zip code (xxxxx-xxxx OR xxxxx) then other column NameAdds will be blank, when ColumnNameAdd1 only contain street name, then the state for that address is found on the next column which is NameAdd2, the same thing happen when NameAdd1 and nameAdd2 only contain person name and stree address then NameAdd3 or nameAdd4 will pick up the State information and zip code for this person address, etc

What technique could possibly I use to get only the state from each record from these 4 NameAdd columns? can anyone offer any thought?
This topic has been closed for replies.

2 replies

Inspiring
September 27, 2008
If the blank fields are null, then the concatonation will be null also. If they are already empty strings, you should be fine.

Char(0) is an empty string. Spaces are char(32). Plus, with the quotes and the dollar sign, what do you think the value of your MySpace variable actually is.
Inspiring
September 26, 2008
this is redbrick syntax. It should give you the general idea.

select concat (nameadd1, ifnull(nameadd2, ''), ifnull(nameadd3, ''), ifnull(nameadd4, '') ) address
from etc

That will get you full addresses. Then, replace all the double spaces with single spaces so you have a space delimited list. Your state should be 2nd from the end.

Make sure you start at the end in someone live on St Joseph St Fort Worth
mega_LAuthor
Inspiring
September 26, 2008
I tried to replace the space with "I" using coldfusion's replace() and it did not work.
I was thinking to create an array when I can make it into 1234 whatever Avenue|STROUDSBURG|PA|18360
Here is my code:
<cfquery name="GetAdds" datasource="#application.maindsn#">
select (NameAdd3+NameAdd4+NameAdd5+NameAdd6) AS FullAddr
From Log
</cfquery>

<cfloop query="GetAdds">
<CFSET MySpace="$char(0)">
<CFSET FullAddBarDelimited=#Replace(FullAddr, "MySpace", "|", "All")#>
</cfloop>