How to get the highest value, lowest value and average value in mysql in php
给我你的怀抱
给我你的怀抱 2017-05-18 10:51:53
0
3
702

There are two fields in database table A, one is the category, and the other is the price
How to calculate the highest value, lowest value, and average price of No. 11 in the category in PHP
One category corresponds to N pieces of price data such as
11, 100
2, 120
11, 101
11, 101
11, 55
11, 99
5, 88
2, 103
11, 170
5, 98

给我你的怀抱
给我你的怀抱

reply all (3)
伊谢尔伦
//数据库连接省略 $data=mysql_query("select MAX(price),MIN(price),AVG(price) from goods where category=11"); $row_data=mysql_fetch_row($data); echo 'MAX:'.$row_data[0].' MIN:'.$row_data[1].' AVG'.$row_data[2];
    阿神

    select MAX(price),MIN(price),AVG(price) where category=11

      伊谢尔伦

      I think it will be easier to find the answer if you remove php when searching and simply think of it as a sql question

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!