Bkay
Bkay

Reputation: 177

How to export MySQL data of given time period?

I need to export my data from a MySQL database, the problem is that I just want to export data of a given time period. Is it possible through phpMyAdmin? If yes then kindly elaborate how.

Upvotes: 2

Views: 4049

Answers (2)

cypher
cypher

Reputation: 6992

Try the BETWEEN operator. For example:

SELECT * FROM some_table WHERE date_column BETWEEN "2012-08-04" AND NOW();

Upvotes: 2

Dhinakar
Dhinakar

Reputation: 4151

You can use Scheduler event in mysql like

CREATE EVENT exportName 
ON SCHEDULE
EVERY 1 DAY
DO
SELECT *
INTO OUTFILE 'C:/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM products

It will export the table data into csv file every day.

Edit :

Kindly Check your scheduler with this commands:

mysql>SHOW PROCESSLIST;

In the result table,see for user→event_handler and Command→Daemon. If this row is not in table,then thats the reason for event failure. And set event handler as follows,

mysql>SET global event_scheduler=ON;

Upvotes: 1

Related Questions