Database smarties -- SELECT on index help
MySQL question as I can't find my answer in the manual and what I try and make up doesn't seem to work.
Basically, here's my table schema:
id = int(4) auto_increment
name = varchar(20)
date_live = datetime
I created an index on the date_live field:
CREATE INDEX date_live ON table (date_live);
Now, my problem is I want to use that index when I run a query against the table, but i only want to select the "date" element and not both "date" and "time" from the "date_live" field -- like a wildcard:
explain select * from table where date_live like '2004-09-22%'
Unfortunately that query doesn't seem to use the index.
This query doesn't work, because some rows have a time element and I need those rows too:
explain select * from table where date_live = '2004-09-22'
Anyone know how to query for just the DATE on a DATETIME field that can use the index I created on it ?
__________________
Your post count means nothing.
|