tengo un problema con la siguiente consulta,
tengo esta que me extrae una fecha de acuerdo a el mes y el dia
Código:
y otra que es igual pero extraigo el mes anteriormysql> select distinct date from reporte where month(date)='08' and day(date)='15' order by date asc limit 1; +---------------------+ | date | +---------------------+ | 2009-08-15 00:29:33 | +---------------------+ 1 row in set (0.00 sec)
Código:
y cuando intento combinarlas de la siguiente manera el resultado es algo inesperadomysql> select distinct date from reporte where month(date)=08-1 and day(date)='15' order by date asc limit 1; +---------------------+ | date | +---------------------+ | 2009-07-15 08:23:42 | +---------------------+ 1 row in set (0.00 sec)
Código:
cuando las combino asi solo me extrae los registros que son dia 15 del mes anterior en este caso 07 "julio" (08-1)mysql> select * from reporte where date between (select distinct date from reporte where month(date)=08-1 and day(date)=15 order by date asc limit 1) and (select distinct date from reporte where month(date)=08 and day(date)=15 order by date asc limit 1) limit 100;
de antemano muchas gracias.
Ya quedo tenia un limit de mas
select *
from reporte
where date between
(select distinct date from reporte where month(date)=08-1 and day(date)=15 order by date asc limit 1)
and
(select distinct date from reporte where month(date)=08 and day(date)=15 order by date asc limit 1) limit 100;