PDA

View Full Version : I need some kind of a loop


HakkieDEV
05-31-2005, 09:24 AM
Hello there,

I would like to know 2 different kind of things.

1)
User should be compared to userstats, all userid's that are missing in user, should be deleted in userstats as well.

2)
userstats should be updated every month with all important (not all) data from user.

user and userstats both have userid for comparison.

Also important to know, can't do a regular loop, since it will try every possible userid, wich is madness, since alot of userid's are already missing (deleted).

Anyone who could help me with the above 2 questions?

Marco van Herwaarden
05-31-2005, 01:09 PM
What userstats are you talking aobut?

HakkieDEV
05-31-2005, 06:54 PM
Modpoints and posts basically. (also usergroupid, membergroupids, stuff like that)
I've stored modpoints and posts together with the userid in a seperate table every month.

Now I would like to update those tables to delete all deleted userid's from them.

BTW, to be a bit more specific, userstats is not a default table, but it holds the data stated above.

Marco van Herwaarden
06-01-2005, 06:06 AM
Can you give the layout of that table please.

HakkieDEV
06-01-2005, 10:33 AM
user: the normal user table (username, userid, posts, modpoints, usergroupid, membergroupids)

userstats: (userid, posts, modpoints, usergroupid, membergroupids)

Example:
Userid 4545 is present in userstats, but has been deleted from user.
I'd like a query that would update userstats, so it would delete userid 4545 from userstats.

Marco van Herwaarden
06-01-2005, 10:47 AM
DELETE FROM userstats where userid not in (select userid from user);
something like that.