ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have two tables in a mysql database: Subscribers and Unsubscribers. Subscribers is a table containing the details of everyone who signs up for our newsletters (email address, name etc). When people sign up for our website they're details are placed in subscribers. When people unsubscribe they're details go into unsubscribers. It's a stupid system. If I have built the system I would have had a binary unsubscribed field in the subscriber table set to one if they choose to unsubscribe. But what this means is that when I want a list of all currently subscribed people, I need to compare the two tables and pull out the details of all the people who appear in the subscribers table but not the unsubscribers table. This is where I fall down. I'm pretty good with standard queries but I've never compared 2. If I was able to use PHP I would write a loop to do this but I have to do this at the command line so I'm stuck. Can anyone help. Much appreciated.
They didn't seem to work. I'm not sure I was clear on what I needed.
I need the EmailAddress of all the users in Subscribers who's NotifyServices field = 1 and who's EmailAddress is NOT in the Unsubscribers table. Sorry for the confusion.
Ok, I finally got it working, but the query is a bit different to the one that you suggested.
Code:
SELECT Subscribers.EmailAddress, Subscribers.NotifyServices, Subscribers.SubscriberID FROM AlertSystem.Subscribers Subscribers WHERE (Subscribers.NotifyServices = 1) AND (Subscribers.SubscriberID NOT IN (SELECT DISTINCT CancelledSubscribers.SubscriberID FROM AlertSystem.CancelledSubscribers CancelledSubscribers));
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.