Sunday, 15 September 2013

MySQL select data across 4 tables (multiple conditions)

MySQL select data across 4 tables (multiple conditions)

Thanks to another user I was finally able to collect some data using this
query:
SELECT r.form, s.value as email
FROM subrecords s join
records r
on s.record = r.id AND r.name = 'question-form'
WHERE s.title = 'email'
GROUP BY s.value, r.form
details on the tables involved in the above query are found at Finding
duplicates in MYSQL table where data is in multiple tables (multiple
conditions needed)
With the above query I get the list of emails that submitted a specific form.
I would need now to find out which of those email addresses is subscribed
to a specific mailing list, Using the "s.value" of the above query which
lists email addresses
I first need to find out the subscriber.subid which identifies each unique
subscriber and their email address, which is where I would join the result
from the query above
table -> subscriber schema
subid | email
Then select from the following table WHERE listid = '33'
table -> listsub schema
listid | subid | subdate | unsubdate | status
Thank you so much everyone for the incredible help!

No comments:

Post a Comment