I have two tables of zip code information, one without city and state fields (2016_Zips), the other is just a list (USZips_V1) of zip codes, the “Zip_Code” field is common in both tables.
I'd like to match the more complete data (with fields for city, state, latitude, longitude, etc) to the basic list of zip codes. This way I can see which zip codes are common for which city (big cities have multiple zip codes).
This is the code I have, but returns:
Syntax error in expression 2016_Zips.Zip_Code
SELECT USZips_V1.Zip_Code, 2016_Zips.Zip_Code, USZips_V1.city, USZips_V1.state_id, 2016_Zips.lat, 2016_Zips.long, USZips_V1.imprecise, USZips_V1.military
FROM USZips_V1
INNER JOIN 2016_Zips ON USZips_V1.Zip_Code, 2016_Zips.Zip_Code;
and based it off of this:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
Here are my table headings:
This is where I want the information added:
This will be where I draw the data from to add to the table above:
Is there a better way to do what I want to do? Is there a glaring error in my statement?
My goal in doing this is to save time matching data between the tables.
This is my expected output:
you have to use =
in your join instead ,
SELECT t1.*,t2.*
FROM USZips_V1 t1
INNER JOIN 2016_Zips t2 ON t1.Zip_Code= t2.Zip_Code;