Mysql select where date = now if Y-m-d H:i:s -
how select
rows of particular day if date format y-m-d h:i:s
?
i.e. i'd select rows like:
where date(datet) = '2013-08-07'
but values are: 2013-08-07 11:23:45
you have solution yourself:
select * tbl date(datet) = '2013-08-07'
assuming datet
datetime
column efficient way of doing since mysql able use potential index on datet
process where
clause.
depending version of mysql where datet '2013-08-07%'
might job using index (since leftmost part of pattern constant). less elegant, think.
edit: matter of fact, testing appears work efficiently varchar
/char
columns too. see http://sqlfiddle.com/#!8/1c2da/1 (click on "view execution plan" see how index used).
Comments
Post a Comment