[thelist] MySQL: Match date within range, give data

rudy rudy937 at rogers.com
Mon Sep 22 21:39:09 CDT 2003

> I want to store some text in a MySQL DB and retrieve it based on a year (A
> B or C) and a date-range, for example, "the Sunday between September 24 -
> 30 (inclusive)"

create table mytable
 ( id  integer auto_increment not null primary key
 , somedate  datetime not null
 , sometext  text not null

insert into mytexttable (somedate, sometext)
 values ( CURRENT_DATE , 'here''s an entry
that spans two lines')

insert into mytexttable (somedate, sometext)
 values ( CURRENT_DATE - 1, 'here''s yesterday''s that doesn''t')

select * from mytexttable
 where year(somedate) = 2002

select * from mytexttable
 where somedate = '2003-09-22'

> The text in question can be saved as ASCII.  I'd like to save line breaks
> but other than that nothing really.  Each entry is probably not even 3-4
> pages long.

text datatype is good for up to 65000 bytes (approx)

use mediumtext if you need more

as far as preserving line breaks, they will be if you can enter them the
way i did above

otherwise there will be functions in your scripting language to help you


More information about the thelist mailing list