![]() |
Need help with sql cleanup script
Hi,
I'm trying to make a cleanup script to delete accoutns from db that aren't used for like a month. I tried much out myself (some examples below) Can someone teach me how to use the correct commands. Tried to look for explanations on google but i didn't find any understandable explanations. Would be nice if someone can advice me on this one. Greetz DELETE FROM user_account WHERE last_logout < 20-8-2005 8:00:00 DELETE FROM user_account WHERE last_logout < 208200580000 DELETE FROM user_account where last_login = NULL |
You basically have it, except data format is incorrect, try
Code:
DELETE FROM user_account WHERE last_logout < 20/08/2005Code:
DELETE FROM user_account WHERE last_ip IS NULLP.S. sorry to pull the chain but, could you please pm me LDragon (Good thing :P) |
don't forget to make note of the account numbers so you can delete the characters to go with it :o the accounts take up very little.. the characters take up the most. especially the user_item
|
Hi i want to thank you both for the nice reaction. :wink:
Now i only need to find out how to convert the time and date together in the script because the time and dae are like this in the db: "10-9-2005 17:28:4" Now i tried only the date but there are no rows affected when i do it like that so i must have the time too but i don't know how to describe the : symbol and in he db there seems to be a space between the date and time wich i can't define too. Greetz LdragonL |
Before u delete any data from db like "DELETE FROM user_account WHERE last_ip IS NULL" think again.
there r also data refering to that account in other tables like ssn, user_auth, etc... I suggest u to do the script which will first check for crossreferences and than delete them all at once if u dont want to have buggy db. |
Quote:
|
No the script doesn't work because in the db there is date with time. When we fill in only the date the script doesn't find any rows matching the script.
i just need to know wich symbol must be replaced in the script for this ":" like 12/4/2005 10:30:00 but the space between it is causing an error too in sql query manager :S |
Re: Need help with sql cleanup script
Quote:
|
Mm yes, it's not as easy as i thought.
But i keep working on it when i learn those darn sql db scripts. |
| All times are GMT. The time now is 15:27. |