mysql>explain select * from tbl_name where date_format(EndTime, '%Y-%m-%d') >= '2007-08-08' AND date_format(EndTime, '%Y-%m-%d') < '2007-08-09'\G id: 1 select_type: SIMPLE table: UserProject type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 1012465 Extra: Using where mysql>set @dt='2007-08-08' ; set @dt1 = '2007-08-09'; mysql>explain select * from tbl_name where EndTime >= @dt AND EndTime < @dt1\G id: 1 select_type: SIMPLE table: UserProject type: range possible_keys: EndTime key: EndTime key_len: 8 ref: NULL
本文转自叶金荣51CTO博客,原文链接:http://blog.51cto.com/imysql/308356,如需转载请自行联系原作者