MySQL代码如下,
表中有MySQL数据库
实际上,
唯一商品组ID 3 (分别为101,102和103) 总物料组ID有23个
101 = 10 ,
102 = 5 和
103 = 8
总计= 23
每个组ID(10或5或8)总数除以唯一组(3)。
round(10/3)= 3,round(5/3)= 2 and round(8/3)= 3
在输出中首先101依次顺序3次,然后依次顺序2次102次,顺序依次顺次3次3次,再次保持上述比率仍然打印所有数据。
输出将如下图所示
请使用MySQL或PHP代码提供答案,
$result = mysqli_query($con,"SELECT * FROM `item` order by(item_group_id)");
echo "<table><tr><th>ITEM GROUP ID</th><th>ITEM NAME</th></tr>";
while($row = mysqli_fetch_array($result))
{
ehco "<tr><td>";
echo $row['item_group_id']
echo "</td><td>";
echo $row['item_name'];
echo "</td></tr>";
}
echo "</table>";
答案 0 :(得分:-3)
$result = mysqli_query($con,"SELECT DISTINCT item_group_id,item_name FROM `item` order by(item_group_id)");
echo "<table><tr><th>ITEM GROUP ID</th><th>ITEM NAME</th></tr>";
while($row = mysqli_fetch_array($result))
{
ehco "<tr><td>";
echo $row['item_group_id']
echo "</td><td>";
echo $row['item_name'];
echo "</td></tr>";
}
echo "</table>";