Forum Moderators: open

Message Too Old, No Replies

Export database records by Year

         

jake66

2:14 am on Jul 7, 2007 (gmt 0)

10+ Year Member



I have database in which I would like to export all records that were posted in the year 2006 in plain text or gzip (holding true to the SQL structure of
INSERT INTO `table` VALUE...
and such)

The dates are stamped as follows: 2006-09-25 21:49:28

I've searched the web for a pre-written script but haven't located one yet. Any suggestions how I can achieve this?

Discovery

5:55 am on Jul 7, 2007 (gmt 0)

10+ Year Member



I am not sure,
But what you can do, Copy Table with Condition [java2s.com],

eg,
CREATE TABLE MyEmployee SELECT * FROM Employee
where Age > 30;

and export a table.

or

You can also export with condition read example in User Comments of the link [dev.mysql.com]

jake66

2:45 am on Jul 11, 2007 (gmt 0)

10+ Year Member



Thank you, I believe I got the SQL portion of it down now.

I just can't seem to get the date specs correct.
Can anybody spot what I'm doing incorrectly here?

select * from table_tobepurged where `date_stored` < DATE(2007-01-01 01:01:01) order by orders_id asc limit 5

jake66

2:58 am on Jul 11, 2007 (gmt 0)

10+ Year Member



Got it to work:
select * from table_tobepurged where date_stored BETWEEN '2006-01-01' and '2007-01-01' order by orders_id asc limit 5