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
https://forums.phpfreaks.com/topic/218537-query-guidance/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.