We might need a little more info on this. A stored procedure usually takes some input, applies some logic, and returns a result.
If the second table already has Zipcode and Congressional District, why do you need to join them? Simply querying the second table would give the desired result.
Making some assumptions…
ZipCode table has a primary key “pkZip”, and a column with the Zip Code, plus possibly other data.
CongDist table has a foreign key on ZipCode with “pkZip”, but doesn’t actually have the ZipCode value, so you need to join the two tables.
<pre>select cd.CongDist, zc.ZipCode
join ZipCode zc on zc.pkZip = cd.pkZip;</pre>
The above query will return the pairs of congressional districts and zip codes.
You can embed that directly in other queries, or if you really need to make a Stored Procedure, it is just:
<pre>create function spfCongDistZip()
join zipcodes zc on zc.pkzip = cd.pkzip;</pre>
You can then use that function just like a table, e.g.:
<pre>select * from spfCongDistZip();</pre>
from myOtherTable mot
join spfCongDistZip() cdz on cdz.zipcode = mot.zipcode;</pre>