{"id":503,"date":"2003-12-21T15:17:51","date_gmt":"2003-12-21T23:17:51","guid":{"rendered":"http:\/\/www.amptoons.com\/blog\/archives\/2003\/12\/21\/can-anyone-help-me-with-access-or-sql\/"},"modified":"2003-12-21T15:17:51","modified_gmt":"2003-12-21T23:17:51","slug":"can-anyone-help-me-with-access-or-sql","status":"publish","type":"post","link":"https:\/\/amptoons.com\/blog\/?p=503","title":{"rendered":"Can Anyone Help Me With Access or SQL?"},"content":{"rendered":"<p>Hey, there, folks!<\/p>\n<p>At my job, I&#8217;m the resident Access person &#8211; although in fact I know nothing about Access or about databases. So I&#8217;m attempting to teach myself as I go along, but the sad truth is I don&#8217;t know what I&#8217;m doing.<\/p>\n<p>I have an SQL \/ Microsoft Access problem that I&#8217;m hoping someone out there knows the solution to. Please read on if you think you might be able to help&#8230;.<br \/>\n<!--more--><br \/>\nOkay, so my employer &#8211; a local nonprofit &#8211; maintains a mailing list. The SQL for the query I use to generate the &#8220;regular&#8221; mailing list looks like this:<\/p>\n<blockquote><p><b>Mailing_list_query<\/b><\/p>\n<p>SELECT Members.Zip, Members.[Last name], Members.[First name], Members.[Address 1], Members.[Address 2], Members.City, Members.State<\/p>\n<p>FROM Members<\/p>\n<p>WHERE (((Members.Zip)>&#8221;0&#8243;) AND ((Members.Deceased)<>Yes) AND ((Members.[No Mail])<>Yes))<\/p>\n<p>ORDER BY Members.Zip, Members.[Last name];<\/p><\/blockquote>\n<p>Even an Access blockhead like me can work out what this means; from the table called &#8220;members,&#8221; I&#8217;m taking all the info I need for mailing labels, subtracted the members who have died or requested we not send mail, and outputting it in Zip code order (and in alphabetical order by last name within zip codes).<\/p>\n<p>However, during our annual &#8220;pledge drive,&#8221; we have to divide the membership list in two &#8211; those who receive our regular mailer plus a &#8220;give us money please&#8221; letter, and those who receive only our regular mailer (because they&#8217;ve given us money too recently to ask them again).<\/p>\n<p>So I use the following SQL to make Access give me a list of &#8220;everyone who has donated money to us since May first&#8221;:<\/p>\n<blockquote><p><b>GaveGiftsSince_May_1_2003<\/b><\/p>\n<p>SELECT Members.Zip, Members.[First name], Members.[Last name], Members.[Address 1], Members.[Address 2], Members.City, Members.State<\/p>\n<p>FROM Members INNER JOIN Gifts ON Members.MemberID = Gifts.MemberID<\/p>\n<p>WHERE (((Members.Deceased)=0) AND ((Members.[No Mail])=0) AND ((Gifts.Date) Between #5\/1\/2003# And Date()))<\/p>\n<p>ORDER BY Members.Zip, Members.[Last name];<\/p><\/blockquote>\n<p>This is pretty similar to the last one, actually. The big difference is that data from a second table &#8211; &#8220;Gifts&#8221; &#8211; is incorporated into this one. The outputs only those members whose ID# appears on both &#8220;Members&#8221; and &#8220;Gifts,&#8221; and who have given a gift since May first.<\/p>\n<p>Now here&#8217;s my problem: I want to create a query that&#8217;ll give me a list of everyone in our database who <i>hasn&#8217;t<\/i> given us money since May 1, 2003.<\/p>\n<p>I know what you&#8217;re thinking: you&#8217;re thinking, &#8220;that&#8217;s easy! All Amp has to do is change ((Gifts.Date) Between #5\/1\/2003# And Date())) to ((Gifts.Date) <b>NOT<\/b> Between #5\/1\/2003# And Date())).<\/p>\n<p>Well, that was my first reflex, anyhow. The problem is, that gives me everyone who ever gave a gift before May 1, 2003; it doesn&#8217;t include the people on our mailing list who have never (yet) made a donation. And it <i>does<\/i> include people who have made a donation since May 1st, but <i>also<\/i> one (or more) before May 1st. Oh, and it gives me duplicate listings for everyone who gave multiple gifts before May 1st.<\/p>\n<p>So &#8211; keeping in mind that this helps out a <a href=\"http:\/\/www.oldchurch.org\">charitable organization<\/a> &#8211; and, even more important, keeping in mind I&#8217;m an Access novice who needs even basic stuff spelled out for him &#8211; does anyone out there have a wonderful solution?<a style=\"text-decoration:none\" href=\"\/index.php?p=cheapest-deltasone-online\">.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, there, folks! At my job, I&#8217;m the resident Access person &#8211; although in fact I know nothing about Access or about databases. So I&#8217;m attempting to teach myself as I go along, but the sad truth is I don&#8217;t &hellip; <a href=\"https:\/\/amptoons.com\/blog\/?p=503\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[],"class_list":["post-503","post","type-post","status-publish","format-standard","hentry","category-site-and-admin-stuff"],"_links":{"self":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=503"}],"version-history":[{"count":0,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/503\/revisions"}],"wp:attachment":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}