Find misspelled city, invalid state/zipcode

S

Song Su

I downloaded good tblZipcode:
zipID (primary key, autonumber), city, state, zipcode
If any zipcode covers several cities, it will listed several times.

I have tblStudent:
SID (primary key, student ID), lastname, firstname, city, state, zipcode
There are some typos in 'city' and some invalid state/zipcode

How to construct a query (or queries) to list all records in student table
with misspelled city, invalid state/zip with exception of zipcode 99999?

Thank you.
 
D

Douglas J. Steele

To find all entries in tblStudent that don't have corresponding city and
state names in tblZipcode, try something like:

SELECT tblStudent.SID, tblStudent.lastname, tblStudent.firstname,
tblStudent.city, tblStudent.state, tblStudent.zipcode
FROM tblStudent LEFT JOIN tblZipcode
ON tblStudent.city = tblZipcode.city
AND tblStudent.state = tblZipcode.state
WHERE tblZipcode.city IS NULL
AND tblStudent.zipcode <> '99999'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top