Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 10:59 AM   PM User | #1
itxtme
Regular Coder

 
Join Date: Jun 2009
Posts: 102
Thanks: 3
Thanked 16 Times in 16 Posts
itxtme is an unknown quantity at this point
does this logic work?

I have a DB that is storing emails to send. I want to have my script send 5 at a time. There are two types of emails, Type A - important, Type B marketing material. I have my script requesting 5 emails to send, now I want it to first choose 5 Type A emails over Type B, easy, however if there are only 2 Type A messages I want it to pick up 3 of the Type B to make it a full round to sned off to the smtp.

Any ideas?

Message 1, Type A
Message 2, Type B
Message 3, Type B
Message 4, Type B
Message 5, Type B
Message 6, Type A
Message 7, Type B

PHP Code:
SELECT A.idA.r_emailB.subjectB.content FROM recipients AS A INNER JOIN content AS B ON B.id=A.id LIMIT 5 
It should be selecting message 1,6,2,3,4
itxtme is offline   Reply With Quote
Old 11-09-2012, 06:23 PM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Code:
ORDER BY
   messagetypecolumn
LIMIT
   5
why the need to send only 5 messages at a time?
guelphdad is offline   Reply With Quote
Old 11-09-2012, 08:18 PM   PM User | #3
itxtme
Regular Coder

 
Join Date: Jun 2009
Posts: 102
Thanks: 3
Thanked 16 Times in 16 Posts
itxtme is an unknown quantity at this point
Thanks for that, I did try that but it was giving an strange order. I added a key and now it is working correctly. 5 was just an arbitrary number I gave, I can in fact send 5 a second but it was more about showing an example to you guys. Thanks again
itxtme is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:56 PM.


Advertisement
Log in to turn off these ads.