Don't look at it as a string, you're not searching on a string. What
you are actually searching on is a range of dates, the first of the
month through the end of the month. That will keep your data in a
date format and use the index.
SELECT ... WHERE date between CONCAT(YEAR(date),"-",MONTH(date),"-1")
AND LAST_DAY(date)
On Jul 16, 2005, at 4:33 PM, Octavian Rasnita wrote:
Hi,
I have a table with a DATE type column and I want to search for
more records
that have the same year and month.
I have tried searching with:
select ... where date_format(date, '%Y-%m')='2005-06' ...;
I know that if I apply a function to the date column, the index on
that
column is not useful and I have seen that this query works very
very very
slow, even though I have defined an index on the date column.
Are there any other ways to create this query in order to make it work
faster?
Thank you.
Teddy
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?
[EMAIL PROTECTED]
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]