MySQL with PHP calculation
I have a question regards of my database and PHP programming.
I have a MySQL database and a table with more than 5 million data on it.
I need to get the data from this table and do the calculation on it.
I have created the index on the database but the process is slow.
First I want to use the data show in data.
for example: product code week1 sales, week2 sales, week3 sales, calculate
avg.
In this table. there are may same product code between different week.
First i'm using the select distinct product from table to get the product
code from table using the php script, while row=mysqli_fetch_array and
then I need to run another sql to get the sales data which is equal to the
product code and run by week and calculate the avg.
Therefore, it takes more than half an hour to run the above query in with
php script. Is there any good suggestion for this situation.
Sorry for my english
No comments:
Post a Comment