robert_gsfame Posted September 11, 2009 Share Posted September 11, 2009 hi guys, i have small problem related to mysql actually... I have let say 500 members for my site, then i would like to send them each an email while i can only send let say 100 in an hour which means i have to send them all in 5 hours each 100 email It's easy if i have my user id, i can just use below code: "SELECT * FROM mytable WHERE id between 0 and 101" -->1st 100 "SELECT * FROM mytable WHERE id between 100 and 201" -->2nd 100 "SELECT * FROM mytable WHERE id between 200 and 301" -->3rd 100 "SELECT * FROM mytable WHERE id between 300 and 401" -->4th 100 "SELECT * FROM mytable WHERE id between 400 and 501" -->5th 100 but the problem is that i don't have id for this user's table in my database..how do i have to retrieve my first 100, second 100, third 100, fourth 100 and fifth 100 every hour DOES ANYONE HAVE A CLUE FOR THIS?? Quote Link to comment https://forums.phpfreaks.com/topic/173888-500-records-retrieve-problem/ Share on other sites More sharing options...
gr1zzly Posted September 11, 2009 Share Posted September 11, 2009 You may want something more like this... SELECT user_email FROM mytable LIMIT 100 OFFSET $offset; LIMIT tells how many records to retrieve and OFFSET which record no. to start from. Then just increment $offset for each exec of the query. Also, forgive me if this is irrelevant, but do you need to retrieve all columns values ( i.e. ' * ' ) for each row or just one or two specific fields? You can select more than one specific field by separating them with a comma. Quote Link to comment https://forums.phpfreaks.com/topic/173888-500-records-retrieve-problem/#findComment-916635 Share on other sites More sharing options...
robert_gsfame Posted September 11, 2009 Author Share Posted September 11, 2009 yeah i got it, i really don't realize that i could use OFFSET ha..ha thanks Quote Link to comment https://forums.phpfreaks.com/topic/173888-500-records-retrieve-problem/#findComment-916640 Share on other sites More sharing options...
cbolson Posted September 11, 2009 Share Posted September 11, 2009 Hi, I realise that gr1zzly has given you the answer but but the problem is that i don't have id for this user's table in my database Begs the question Why don't you have ids? Pretty much all database tables should have an autoincrement id KEY field, I can't imagine a situation where this shouldn't be the case. Anyway, you have the solution, just though I would mention it Chris Quote Link to comment https://forums.phpfreaks.com/topic/173888-500-records-retrieve-problem/#findComment-916643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.