Removing Data After A Certain Period Of Time
What I want to do is run a query that inserts data into my database, but removes itself on a set date. Is there any way to do this?
Basically, I have something like this:
INSERT INTO table (blah, blah2) VALUES (blah blah, 1)
I would like to do something like:
INSERT INTO table (blah, blah2) VALUES (blah blah, 1) {{{ INSERT CODE TO MAKE VALUES GO AWAY WHEN CURRENT TIME = SET TIME TO GO AWAY }}}
There is an alternative to this if I have to. This is all for a PHP script, and instead of having MySQL automatically remove the data, I could add a time to remove to the table, insert the value for it in the INSERT query, and run a query on the index page consisting of something like
<?php
$timeToRemove = SELECT_TIME_TO_REMOVE_FROM_DB;
if($currentTime => $timeToRemove)
{
REMOVE;
}
?>
so that every time someone hit the index page, it checks if it is time to remove the values from the DB and if it is, it does so. But of course, that adds an extra query/queries, and I'd like to avoid that.
Edit: It may be useful to note that this is for a message board system, and I am dealing with making usergroup changes temporary. So instead of removing the values, perhaps it would be more useful if I could simply have MySQL reverse itself after a certain time has passed.
But that seems unrealistic for some reason now that I think about it, so the alternative may be my best choice. Any suggestions from you all would be nice as well, if you've any ideas.
View Complete Forum Thread with Replies
Related Forum Messages:
Dumping Data From A Certain Time Period
Every time I make changes to my MySQL database on my local PC, I have to dump the whole table on the server. This can get a bit annoying when the table contains thousands of records.Is there a way for MySQL to log all the updates you've made since a certain time and then use this file to dump it on the server?
View Replies !
Time Period Results
Can anyome tell me the php script to return data from a table which is less than 24 hours old. I have a timestamp on my table when data is added.
View Replies !
Generating DAILY Min&Max Over A Period Of Time, Based On A "DateTime" Field
how to print the minimum and maximum of a specific field, between two datetimes (both having the time 02:00:00) - so I did this: WHERE ((tblvalues.dtLPDateTime)>="2006-01-01 02:00:00" And (tblvalues.dtLPDateTime)<"2006-01-03 02:00:00")) Now I want to print those min and max values but for each day in this cycle, i mean, for this example, there would be two records like: Day Min Max 2006-01-01 02:00:00 -> 2006-01-02 02:00:00 | 40 | 59 2006-01-02 02:00:00 -> 2006-01-03 02:00:00 | 49 | 68 where at this point i`m getting min=40 and max=68
View Replies !
Room Reservation: See If A Time Period Is Open For A Particular Room...
this is stumping me... i need to see if a time period is available for a something (in this case a room reservation). it's not as simple as starttime < end and endtime > start... for example a room is scheduled from 12:00 to 1:00pm and from 2:00 to 3:00pm. how can you check if a user entered: from 1:00pm to 2:30pm? i'm trying to UNION but that doesnt seem to work. subselect?
View Replies !
Removing MySql Data
I saw the post by The Only One but found a much better tutorial. I have the code to remove the data: DELETE FROM testfield WHERE id='$id' Does this only delete the user with that ID or can I make it search for a user name and remove that? Would it be: DELETE FROM testfield WHERE username='joe blogs'
View Replies !
Add A Period 5 Places From The Right?
I'm trying to modify some latitude/longitude columns which have the values like: 3482787, -11782842 They're stored in text fields currently. I basically just need to put the decimal in the proper place, which should always be 5 places from the right, so i need to make the above value (and the other 6.3 million rows) look like this: 34.82787, -117.82842 I cant seem to find the function syntax to do this in MySQL, tho I'm sure it exists. I dont want to write a PHP script to do this because it seems like PHP chokes on me if I work on more than 500 thousand rows at a time.
View Replies !
Grouping By A Date Period
Let's say I have a table with dates that range from January to May in each record. Is it possible to group the records by a date range, for example: I want to group the records by a date period of 1 month, starting at the 3rd day of each month. So what I'd want to see is, five records for each month (jan 3 to feb 3, feb 3 to march 3, march 3 to april 3, april 3 to may 3).At the moment I have the following: select id, _date, sum(cost) from test where _date >= ' 2005-01-03' and _date <= date_add('2005-01-03', interval 1 month) group by extension union select extension, _date, sum(cost) from test where _date >= date_add(' 2005-01-03', interval 1 month) and _date <= date_add('2005-01-03', interval 2 month) group by extension The trouble with this is that each month interval has its own select query and that the increase in the month is hard coded (interval 1 month for example). Is it possible to use SQL to inrement the month?
View Replies !
Selecting First Occurance In A Given Period Of Record
I have a table to log sessions and user (connect_id) id's, start time etc - see below +---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | connect_id | varchar(12) | | | | | | session_id | varchar(32) | | | | | | start_time | int(11) | | | 0 | | | client_ip | varchar(16) | | | | | +---------------+-------------+------+-----+---------+-------+ I need to create a report that will tell me, for instance, how many sessions were started today, that's easy I know but I also need another report that will tell me how many of those sessions were first-time visitors.
View Replies !
Date Calculation For 24 Hour Period
I would like to automatically get the number of assignments received between a 24 hour period for the past 8 days. I am using "where received >= date_add( now() , interval -1 day)" to get yesterdays assignments....
View Replies !
Select And Displaying 90 Day Interval Over A Period
SELECT DATE_ADD('2008-09-07', INTERVAL 90 DAY) What I'm basically after is to display a range of dates with a 90 day interval till a given date. As per the nultiple select statements below. SELECT DATE_ADD('2008-09-07', INTERVAL 90 DAY) SELECT DATE_ADD('2008-12-06', INTERVAL 90 DAY) SELECT DATE_ADD('2009-03-06', INTERVAL 90 DAY) SELECT DATE_ADD('2009-06-04', INTERVAL 90 DAY) SELECT DATE_ADD('2009-09-02', INTERVAL 90 DAY) SELECT DATE_ADD('2009-12-01', INTERVAL 90 DAY) SELECT DATE_ADD('2009-12-01', INTERVAL 90 DAY)
View Replies !
Data Time
I am very new to program database driven application. I current using ODBC with the help of ADODB funciton to access the MySQL database to store and search for data stored in it. Every time I do a store function or seach function, I takes about five seconds to finish the job. As my database only have about 5 or 6 datas only. I am afraid that it take longer when my database size increases let say 5000 datas in it. Any way to speed up the process? Please help
View Replies !
Time Data Type
I have a column of data that represents a racing participants race finish time where time is measured with fifths of a second. I currently have the column stored as a varchar(4) data type because i could not figure out how to store it as a time and keep all my data. Here's an example of some of my 4 character stored data, followed by the explanation of what it really means. 2014 which means 2 minutes 1 second and four fifths of a second 1590 which means 1 minute 59 seconds and no fifths of a second 1561 which means 1 minute 56 seconds and 1 fifth of a second 2003 which means 2 minutes no seconds and 3 fifths of a second Is there any way i could get this into a time data type that won't lose the fifth of a seconds? I want to be able to output it in a human readable format like 2:01.4 1:59.0 1:56.1 2:00.3
View Replies !
Data Type For Storing Time
I need to store times in my database. The times will be in the format of 10:15.03 minutes:seconds.milliseconds. Which data type should I select for the field in the table? I will want to be able to sort them into order ie quickest first and also calculate the differences between each time.
View Replies !
Displaying Row Data Only When Occuring First Time....
Please have a look at the following query: mysql> select * from t1 where person in ('G.W. Bush', 'Saddam Hussein'); +----------------+-------------+ | person | disease | +----------------+-------------+ | G.W. Bush | dyslexia | | G.W. Bush | cretinism | | G.W. Bush | alcoholism | | Saddam Hussein | sore throat | | Saddam Hussein | dyspnea | +----------------+-------------+ 5 rows in set mysql> Now my question: Is it possible to format the output in a way, that only the first occurrence of 'person' is displayed? Like: +----------------+-------------+ | person | disease | +----------------+-------------+ | G.W. Bush | dyslexia | | | cretinism | | | alcoholism | | Saddam Hussein | sore throat | | | dyspnea | +----------------+-------------+ 5 rows in set mysql>
View Replies !
Real Time Data Feed
I am currently looking for a solution for a project that I have been given. I am looking for a way to capture/store a real time data feed from a PABX that contains call records (time of call, who called, what number etc...). I have written all of the queries and the other tables associated with this, but I need to know how to capture the data that is Pushed from the PABX to the server. I would know how to do this if I had to go and pull the data, but the PABX outputs the data in a continuous stream and this is my issue.
View Replies !
Data Containing Disjoint Time Intervals
I have an Activity table: create table Activity( id integer, startTime integer, endTime integer ); I know that all Activities are non-overlapping in time, but I cannot see a way to state this in SQL. Each Activity has number of Events, in a separate table. I am trying to avioid storing the activity iD for each event. There are likely many events per activity. create table Events( type int time integer ); I then create a view so I can easily see each the Activity in which each Event falls: create view v as select E.type, A.id, E.time from Activity A, Event E where time >= startTime and time <= endTime
View Replies !
Any Way To Insert Data Into Two Tables At The Same Time?
what I have is a table called `order` and a table called `lmcharge`. a person inputs data from a form and i need to take the data from both and some goes into one table, some goes into another here is an example: order values: student_id, class_id, order_type, date, status //student_id, class_id, order_type will be from the form lmcharge values: student_id, order_id, lm_number //student_id, and lm_number will also be from the form but order_id will have to be from the order table anyone have a clue?
View Replies !
Reduce Data Loading Time
At present i am working with a database that contains all countries and their cities. My database is in mysql. The city table contains 3079703 cities. When a user selects a country i need to populate the city dropdown for that country. I use Ajax technology to retrieve city from database based on the selected country. But I am facing a problem with the speed as it takes a long time to retrieve city data and return generated dropdown control from server using php. I have already tried to use filebased caching (transferring all the city data into separate files for each state and country) and then tried to load from these files but didn't gain any significant speed improvement. I also then tried using indexing in city table on country code and state code but it still takes time to load. Could someone please give me any techniques or optimisation tips so that i can load the cities within a short time.
View Replies !
Inserting Time Data Into MYSQL
I'm trying to insert an assortment of data into a mysql database. Although I'm having problems when inserting fields with time information. Firstly, it's outputting it as HH:MM:SS and I need it to output as HH:MM. It's also defaulting as "00:00:00" even if I leave it blank. I've set it up as TIME and set the default as blank and NULL ...
View Replies !
Real-time Data Store And Analyize
I need to accept real-time quotes from quote provider and do real time analysis, would MySQL fill any gaps in whatever is needed to accomplish this? So, the steps would be, Connect to the data provider using either web browser or their proprietary package. Connect using MySql to store the quotes. Run my algorithm live on the data stream. Store the results in the data base for further use.
View Replies !
Real-time Automatic Conditional Data Manipulation
So it happens that I have to delve into the fields I feel very uncomfortable in ... for now. I'm working off the existing MySQL DB, in which I have to: 1. Analyse in real time (or nearly there) every newly entered row in the "entry" table (data is inputed by a third party) based on the set of criteria and depending on the outcome create new entries either in "bad" or "good" tables 2. Perform the same operation but on the different set of criteria on the new entry in the "good" table and create new record in the "output" table, which is then visible to the third party (but contains very different data from originally entered) My original plan was to dive into writing triggers, but this feature does not seem to be supported in the platform of my choice. Are there any GUI tools (or anything that would not require PhD in quantum physics) that can help me to create conditional real-time updates between tables within one MySQL database triggered by appearing new record?
View Replies !
Creating Datetime Data Object From Date And Time Objects
I have date and time objects that correspond to eachother. I want to add a certain amount of minutes and hours to them and get the resulting date and time. I was planning on creating a datetime datatype from the two and then using the date_add() function and then convert back; however, I do not know how to create a datetime object from two seperate date and time types and then back to seperate types, or whether it is even possible.
View Replies !
Converting Time Date Values To An Absolute Number For Data Retrieval
We have a medical DB which stores several medical variables from real cases. We use this data to build display trending information on a visualization display for doctors. Pulling and rendering graphically ALL the data takes time and processor that may not be available in a real world situation. What we want to do is to pull data at specific intervals of time based on the time length a doc wants to view. For example: if we have 2500 records all of which have a time stamp and each record is for an interval of 15 seconds how can I query the DB such that I can pull every data point at an interval of 75 seconds apart from the beginning time and display it? I was thinking if I could convert the timestamps to an absolute numeric value (assuming MySQL starts it's times at some point in the past) then I could figure out the query from there.
View Replies !
Removing Subqueries
the query i want execute is: select email from avalia where email in (select * from avalia where nome=´img/im1.jpg´) and email in (select * from avalia where nome=´img/im2.jpg´) but mysql 4.0 don't acept subqueries.
View Replies !
Removing End-of-lines
I have a field in a table that I need to scan through and remove all end-of-line chars excepts for an end-of-line that is immediatly follwed by an end-of-line. Does this make sense?
View Replies !
Removing AUTO_INCREMENT
I need to remove the auto_increment directive from a table, but so far I'm not having any luck. I tried alot of variations on ALTER TABLE/MODIFY but I get errors. I could dump the table, remove the auto_increment from the CREATE query, DROP the table and reload, but I'd rather know how to do it right than use a stupid work-around.
View Replies !
Removing Emails
I have a master table list of emails (masterlist). I have a second table (removelist) with emails that I want removed from the master table list.I have tried.Code: DELETE FROM masterlist WHERE email IN (SELECT email FROM removelist) but get You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT email FROM removelist)' at line 1
View Replies !
Removing Fields
Is there anyway to delete all the rows that have a certain field with less than say 5 characters from a table? I have a table with entries that are like "efg" or something that don't make sense. I need to get rid of all of them.
View Replies !
Removing Spaces
I've got a MySQL database where a silly user input a whole bunch of records with spaces at the end.Is there an easy way to get rid of those spaces without having to re-input the records again?
View Replies !
Removing A Domain
I added a new domain but by mistake i inserted an incorect username from what the client wants. how can i change it, or remove the user and redo it.
View Replies !
Removing Users
I can't seem to figure out how to remove users with php. I tried to do it with this $query = mysql_query("REVOKE ALL PRIVILEGES, GRANT OPTION FROM user"); Where user is the name of the user I want to delete. That's what it said to do in the GRANT/REVOKE syntax part of the site but it doesnt do anything when I run the script.
View Replies !
Removing Old Versions
I loaded a new version of Mandrake Linux 10.0 CE and have also installed and dowloaded a new version of MySQL 4. I'm not sure but think I have several versions installed and running ... How can I check to see what is installed, what is currently running, and then perhaps remove them all and start by installing single new copy?
View Replies !
Removing Last Character
i want to do substring each value of a particular column in my table so that the last character disappear. value of the orignal one eg. 12321% value of the edited one eg. 12321
View Replies !
Removing 14,000 Entries
I have a MySQL database that has 14,000 entries in it. I am using phpMyAdmin to maintain the database. I have a column called ID that is set to auto increment. I just removed 100 rows to try and fix and issue but my index number is still showing the original number of entries. is there some way i can update this so that the index number matches and updates when I remove rows? I am getting weird outputs from this. newer entries are showing behind old ones? Any help or thoughts would be great.
View Replies !
Setting Up / Removing
I tried removing MySQL But when asked for my password it would let me type it & Im log in as admin. Please Help ASAP I need a MySQL Project done. here is the terminal line: [flash-AlPB-1GHz:/usr/local] chadelso% [flash-AlPB-1GHz:/usr/local] chadelso% cd /usr/local/mysql [flash-AlPB-1GHz:/usr/local/mysql] chadelso% cd /usr/local sudo rm mysql sudo rm -rf mysql-3.23.47-apple-darwin5.1-p [flash-AlPB-1GHz:/usr/local] chadelso% sudo rm mysql Password:
View Replies !
Removing Rows
I'm trying to find out how I can remove certain rows of a particular table after, for example, half an hour. The table includes a timedate field for this purpose. Does MySQL(4.1.13) include anyway of doing this, or will I need to create some sort of "house cleaning" program and scedule it in the opperating system? Edited 1 time(s). Last edit at 03/08/2006 09:23AM by Phil Couling.
View Replies !
Removing A Record
Is it possible to remove a record from a webpage. What i want to do is on the last page, delte the record i have built up with inserts and updates.
View Replies !
Removing Old Items
I have a mysql table that stores temporary session items, but I don't want the table to get huge. What would be the best way to automatically delete old items that aren't being used anymore? I could use a timestamp, but this will only be good through the year 2038. I don't want this function to stop working 32 years from now. Any suggestions?
View Replies !
Removing Mysqld-net.exe
Recently I removed MySQL 4.0.15 from my pc, but have noticed that a process called 'mysqld-nt.exe' is still running in the task manager. I have tried shutting down and uninstalling the service via the command line, but since the mysql directory no longer exists the system reports there is nothing to remove! Should I re-install mysql 4.0.15 and try un-installing it again, or does anyone know a quicker way to fix this problem?
View Replies !
Removing Space In Varchar
i have a problem to make a transtype from field XX varchar(20), example : 19 200 340,56 to field YY integer, required : 19200340 I make two replace - first for replacing the , by a . - second for replacing the space by '' (nothing) and a cast : insert into table2 select cast(replace(replace(XX,',','.'),' ','') as unsigned) from table 1 ; The problem is the first replace. The space is not recognized. Even for example with others commands related to string. If I put any other caracter, it works. Does anyone have any solution ?
View Replies !
Ordering Results (removing 'the')
If i have a list of titles (ex. movie titles). What would be the best way to order these results without the preceding word "the". Would I have to use a case statement or something. After reading the mysql manual some more. I came up with this. select * from titles order by IF(INSTR(title, 'the') = 1, substring(title from 5), title) Its wrong i Know, but am I even close?
View Replies !
Removing Auto-increment
I would like to change one of the fields (primary key field) in my table to not auto-increment. The table is still empty. Can I do this without having to drop the table and recreate it again?
View Replies !
Removing Extra Numbers In Avg()
I have a sql query that will grab the average of all votes and display them to the screen. However what I want to know is right now is it will display right now an average as 4.9500 is their a tag or php or sql function (in mysql) to make this display as just 4.9 or even 4.95 and drop off any other numbers?
View Replies !
|