报错写法
<?php include 'conn.php'; ?>
<?php
$sql="SELECT
sku_p as SKU,
'MFN' AS ddd,
sum(case when (transaction_type ='Order' and amount_type='ItemPrice' and amount_description='Principal') then quantity_purchased else 0 end) AS 阿斯蒂芬
FROM
tongji
WHERE fulfillment_id='MFN'
GROUP BY sku_p
HAVING COUNT(sku_p) >= 1;";
$result = $conn->query($sql);
echo $result->num_rows;
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["SKU"]."<br>";
}
} else {
echo "0 结果";
}
$conn->close();
?>
不报错写法
<?php include 'conn.php'; ?>
<?php
$sql="SELECT
sku_p as SKU,
'MFN' AS ddd,
sum(case when (transaction_type ='Order' and amount_type='ItemPrice' and amount_description='Principal') then quantity_purchased else 0 end) AS ttt
FROM
tongji
WHERE fulfillment_id='MFN'
GROUP BY sku_p
HAVING COUNT(sku_p) >= 1;";
$result = $conn->query($sql);
echo $result->num_rows;
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["SKU"]."<br>";
}
} else {
echo "0 结果";
}
$conn->close();
?>