list all zip to zip permutations

I have a zip code listing and need to create a zip to zip listing. The order of the zips do matter so if I have 01001 to 17325, i still would need the reverse too, 17325 to 01001. I don't think I can do this in excel because of the 1 million row limit but can I do this in sql?
LVL 1
k1ng87Asked:
Who is Participating?
 
deightonConnect With a Mentor progCommented:
SELECT t1.zip, t2.zip FROM YourTable t1 JOIN YourTable t2 ON T1.zip <>T2.zip
0
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
Pretty simple code ...

select a.zipcode FromZip, b.zipcode ToZip from zip a, zip b where a.zipcode!=b.zipcode;

Open in new window


Drop the "where" if you also want same zipcodes listed as from and to ...
0
 
Anthony PerkinsCommented:
And that is going to be a big table, with somewhere around 2.5 billion rows.
0
 
k1ng87Author Commented:
yeah...i dont think this is going to be practical as the row count will be insane...but the solution did work!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.