我希望能够将所有价格乘以我的数据库,然后将总数乘以10.
下面的代码执行加法而不是乘法
<?PHP $d = $_GET['d']; $con = MysqL_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . MysqL_error()); } MysqL_select_db("databasename",$con);// $sql= "SELECT SUM(prices) FROM tablename WHERE Date = '$d' AND Prices >0.20 AND Type= 'sold'"; $results = MysqL_query($sql); $row = MysqL_fetch_array($results); echo $row[0]*10; MysqL_close($con); ?>
例
id prices 1 25 2 36 3 45
那就是我想要25 * 36 * 45 * 10而不是25 36 45 * 10
希望有人可以提供帮助
这会有效,有限制(数字应该只是正数):
原文链接:https://www.f2er.com/php/138891.htmlSELECT 10 * EXP(SUM(LOG(prices))) AS result FROM tablename WHERE ...
thnx应该去Napier
和他的奇妙发明,logarithms