|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-02 12:10 UTC] sniper@php.net
[2003-03-04 10:33 UTC] yvan dot garnier at laposte dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 08:00:01 2025 UTC |
Query with grouping options return row twice when trying to have associative array as result : $sql ="SELECT MAX(date_send) AS max_date,idmess FROM sending WHERE user='me' GROUP BY idmess HAVING max_date<(NOW()-INTERVAL 1 MONTH)" $res_sql=mysql_query($id_cnx,$sql) Using any of : $res = mysql_fetch_array($res_sql,MYSQL_ASSOC) or $res = mysql_fetch_assoc($res_sql) foreach ( $res as $field=>$value ) { echo "field name ".$field." value = ".$value } This return each row twice with the same values while MAX function with GROUP BY would return only one This query works fine in MySQL console This is also running correctly using mysql_fetch_objet while ( $res = mysql_fetch_object($res_sql)) { echo "field name ".$res->idmess." value ".$res->max_date return only one row per value