Click to See Complete Forum and Search --> : SQL Question


Bantam
February 3rd, 2003, 02:31 PM
Jacob the n00b is back... I should have probably posted this on the database forum, but it doesn't seem visited often and this will be used in VB, indirectly, so...

Background: My college needs a mailing list sent out to everyone who attended attended any of the camps its sponsored within the last few years. I've had to import an old, inefficient FoxPro database, and now have it in a regular MS Access DB format. The problem with the old database is that there is an entry for every single camper and councilor for each of his or her times attended. I.E. - I attended camp three times, from 2000 to 2002, and so I'm in the database three times.

Problem: I need an SQL query to search through the database (which I've cleaned up significantly) and return records needed for a mailing list. There are multiple records with the same address (two sisters going to camp, or a father as a councilor and a son as a camper, etc), but I only need one record returned per mailing address. All the fields I need are contained in a single table, and I only need a few fields (fldLastName, fldStreetAddress, et cetera).

I'm sorry I keep buggin you wonderful forum people. I don't deserve the job I have. I don't know how I even got it. I suck. I should give all the money I make to all of you... but I'm not :P I don't make enough anyway.

-Jacob

Bantam
February 3rd, 2003, 03:15 PM
Note that I can do multiple queries and such, that'd be no problem... or have a number of tables if necessary

Temperance
February 7th, 2003, 03:25 AM
I'm not exactly sure I understand what you want, but here goes.


1) If you only need to get the mailing address then just run

select disitinct (mailingAddressField) from theTable

2) if you need that persons information then just run the same query as above, but add the key information to the distinct clause

ex.
select distinct firstName,LastName,IDNr,MailingAddress from theTable

3) alternatively if you need to remove the excess records permanently, just load the 2) query into a tmpTable, delete all the records out of theTable and the load the tmpTable back into the first table

hope it helps