Jump to content

500 records retrieve problem


robert_gsfame

Recommended Posts

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??

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/173888-500-records-retrieve-problem/
Share on other sites

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.

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

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.