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

Link to comment
Share on other sites

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

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.