Etienne, > Well i hope someone will be able to give me a solution... > Here s my problem: > I'm working with a hudge mysql table (about 15 columns and 1000000 rows...) > > in fact i ve got to count the number of couples `ncompte`/`naffaire` in the > table and finaly calculate the number of couples that appear once, twice.... > > here is the query i do: > $result = mysql_query("SELECT count(*) FROM datas GROUP BY `ncompte`, > `naffaire`"); > > its result like something like this: > count(*) naffaire ncompte > 4 affaire1 compte1 > 4 affaire2 compte2 > 1 affaire3 compte3 > 2 affaire4 compte4 > 1 affaire5 compte5 > > (plus many more) > > > my final result should be: > $result[1] : 2 > $result[2] : 1 > $result[4] : 2 > > I manage to do this quite easily but i use a while instruction... > > while($row = mysql_fetch_array($result)) { > array_push($suite, $row["count(*)"]); > } > > As my table is very long the while takes a lot of time to complete... > So my question is : Is there a solution to return my array as follow : > > 1 2 3 1 4 7 > 4 5 6 ===>> 2 5 8 ??? > 7 8 9 3 6 9 > > It would allow me to not have to use this long long while.... > So if someone could telle me how to modify my query or what instructions to > use to do that...
=there are various functions in PHP to 'reverse' arrays, but I must confess that I have never used them. Regardless, if there is one to suit your purpose, it will surely consume CPU time to achieve the swap-over of 15M items. =your example "my final result should be:" talks of enumerated arrays, so I shall assume this is the way you always use them. =you want to somehow achieve: array[1][1] = array [1][1]; array[1][2] = array [2][1]; array[1][3] = array [3][1]; etc (you know that you can't do the above, right!?) =thereafter the array would be processed by using a mechanism such as two nested FOR loops to iterate through the row/column elements of the array, eg for ( i=1; i<15; i++ ); for ( j=1; j<1000000; j++ ); process( array[i][j] ); etc =can you leave the array where it is, and adjust the way the iterations are managed? Instead of proceeding methodically by counting 'up', count 'down', eg for ( i=15; i>0; i-- ); for ( j=1000000; j>0; j-- ); process( array[i][j] ); etc =Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]