Re: Off-Topic: Sql en Mysql
| From: | Jaime A. Chavarriaga L. | Date: | Wed, 20 Mar 2002 19:34:50 +0000 |
| Subject: | Re: Off-Topic: Sql en Mysql | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-20603@lists.php.net to get a copy of this message | ||
Julio...
que versión es el MySQL de Windows... y que version es el MySQL de Unix !!
> You have an error in your SQL syntax near '(itime), MONTH(itime)
> ORDER BY itime DESC LIMIT 0, 30' at line 1
al parecer el error es en el YEAR...
> El sql que se genera es el siguiente:
> SELECT UNIX_TIMESTAMP(itime) as itime FROM nucleus_item
> WHERE iblog=1 and UNIX_TIMESTAMP(itime)<=1016562888
> GROUP BY YEAR(itime), MONTH(itime) ORDER BY itime
> DESC LIMIT 0, 30
YEAR es un tipo de datos de MySQL...
http://www.mysql.com/doc/Y/E/YEAR.html
y una función de manipulación de fechas
http://www.mysql.com/doc/D/a/Date_calculations.html
http://www.mysql.com/doc/D/a/Date_and_time_functions.html
DATETIME y TIMESTAMP son también tipos de datos
http://www.mysql.com/doc/D/A/DATETIME.html
UNIX_TIMESTAMP retorna la cantidad de segundos desde 1980... YEAR y MONTH
necesitan un date... no pueden recibir un UNIX_TIMESTAMP
para convertir (de nuevo) a fecha (DATE) puedes usar...
FROM_UNIXTIME(unix_timestamp)
FROM_UNIXTIME(unix_timestamp,format)
ver...
http://www.mysql.com/doc/D/a/Date_and_time_functions.html
> Ahora el codigo que permite todo esto es asi:
>
> $query = "SELECT UNIX_TIMESTAMP(itime) as itime FROM nucleus_item"
> . " WHERE iblog=" . $this->getID()
> . " and UNIX_TIMESTAMP(itime)<=" . $this->getCorrectTime() // don't show
future items!
> . " GROUP BY YEAR(itime), MONTH(itime) ORDER BY itime DESC";
> $res = sql_query($query);
ese comentario no te causa problemas ??
8-)
jaime