这里我试图从mysql中的表的特定列中获取15行中的5个特定行。
$sql = "SELECT SUM(column) FROM Table WHERE business_name= 'my business'";
$result = $conn-> query($sql);
$row = $result -> fetch_assoc();
print_r ($row);
Array ( [SUM(rating)] => )
答案 0 :(得分:1)
尝试Count(*)
$sql = "SELECT COUNT(*) AS 'column' FROM Table WHERE business_name= 'my business'";
答案 1 :(得分:0)
您必须使用别名。 $sql = "SELECT SUM(column) as ss FROM Table WHERE business_name= 'my business'";
然后使用$row['ss']
$sql = "SELECT SUM(column) as ss FROM Table WHERE business_name= 'my business'";
$result = $conn-> query($sql);
$row = $result -> fetch_assoc();
echo $row['ss'];
我希望它有所帮助!