我今天从许多不同的方式对此进行了攻击,我还没有想出显示数据的最佳方式是使用可以显示在一个表中的单个查询。问题是我要组合三个查询,但进展并不顺利。我觉得它很接近但显然不正确。
$sql = (SELECT SUM(datamb) AS value_sum FROM maindata GROUP BY phonenumber UNION select dataplan as currentplan from maindata
GROUP BY phonenumber UNION SELECT DISTINCT phonenumber AS value_sum1 FROM maindata);
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)){
echo "<TABLE id='display'>";
echo "<td><b>Data Usage This Period: ". ROUND ($row["value_sum"],2) . "MB</b></td> ";
echo "<td><b>Data Plan: ". $row["currentplan"] . "</b></td> ";
echo "<td><b>Phone Number: ". $row["value_sum1"] . "</b></td> ";
echo "</TABLE>";
}
问题是我想要三列数据,而我只得到一列包含所有数据