Jump to content

Query Guidance


tmh766

Recommended Posts

Hi I can write this in multiple queries but I was hoping it would be possible to combine this into one.

 

I have three tables:

`mail`========================= #Contains a list of messages and their owning business ID.
`businessId`,`message`,`sent`

`business`====================== #Contains a business ID and a CSV of user IDs subscribed to to receive messages from this business.
`businessId`,`name`,`userIdCsv`

`user`========================= #Contains a user ID and their email.
`userId`,`email`

My goal is to first get all messages in the `mail` table that have not been sent (sent=0). Then for each each unsent message, for each `businessId` send a message to all user's emails. In other words, for each message where `sent`=0 I am trying to get rows with `mail`.`message`,`business`.`name,`business`.`userIdCsv`. Can anyone suggest a way to actually get `user`.`email` too all in one query instead of a CSV of user IDs?

 

Any guidance would be appreciated!

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.