i have a table called 'App' contains
ID | Name | Developer | price | downloads
1 | App1 | App Developer | Free | 5
i am using this code to get max downloads
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$mostappdownloaded = mysql_query("SELECT MAX(downloads) as maxdownloads FROM app")
or die(mysql_error());
while($infomostdownloadapps = mysql_fetch_array( $mostappdownloaded )) {
echo $infomostdownloadapps['maxdownloads'];
}
i want to get the developer field value from the row that contains max downloaded app
any help ?
NO need to do fancy things just add developer in your query and you will get your desired output.
$mostappdownloaded = mysql_query("SELECT MAX(downloads) as maxdownloads,Developer
FROM app ")
try this with a subquery
SELECT Developer FROM App WHERE downloads = (SELECT MAX(downloads) as maxdownloads FROM app);
It can be possible that there are several records with the same max numbers of downloads
SELECT Developer FROM App ORDER BY downloads DESC LIMIT 1
您可以从下面的查询中简单地获取开发者在哪个应用程序中拥有最大下载量
select developer from app where downloads = (select max(downloads) from app)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.