Hi all,
I hope someone can help me with this. I have an email manager which takes batches of emails and sends them out. Currently I have the following sql (which works) to limit the emails it sends to subscribers of a particular list.
Quote:
sql = "SELECT subscribers.* FROM subscribers LEFT JOIN " & _
"(SELECT * FROM emailssent WHERE emailssent.batch = " & session("batch") & ") AS es ON subscribers.email = es.email " & _
"WHERE (((es.email) Is Null)) and subscribers.unsub = -1 and subscribers.list = "&session("list")&" ;"
|
Session("list") holds the list ID of the email list. Emailssent holds the emails that have already been sent in that batch (so if something goes wrong they are not sent to again).
What I need to do (and have done for the rest of the site) is break the list out into a separate table. The new table is called subTo and contains subid (a reference to the id fied in the subscribers table) and listid (same thing but with the lists table). Now I need to add that on to the sql statement and only pull out those email addresses that are subscribed to certain lists.
So, what I thought might work is the following:
Quote:
sql = "SELECT subscribers.* FROM subscribers LEFT JOIN " & _
"(SELECT * FROM emailssent WHERE emailssent.batch = " & session("batch") & ") AS es ON subscribers.email = es.email LEFT JOIN " & _
"subto ON subscribers.id = subto.subid " & _
"WHERE (((es.email) Is Null)) and subscribers.unsub = -1 AND subto.listid = "&session("list")&";"
|
Unfortunately it doesn't. I am getting a 'Syntax error (missing operator) in query expression ' error. Now I don't know whether the expression is totally wrong or I am just being let down by my bad syntax.
Could someone please help me. I'm honestly not sure where to go next with this.
All the best,
Steve