试图从表中调出每种类型的项目,我已经在我的sql查询中放入group by语句但它仍然回显出重复的数据。
这是代码和数据库示例
<?php
$con=mysqli_connect("localhost","root","root","test");
$sql = "SELECT * FROM testing GROUP BY Name";
$result = mysqli_query($con, $sql);
while ($row = mysqli_fetch_array($result)) {
echo $row['name'];
echo "<br>";
}
?>
答案 0 :(得分:0)
以下是您可以尝试的代码..
<?php
$con=mysqli_connect("localhost","root","root","test");
$sql = "SELECT distinct name, Record_ID, Shop_ID FROM testing";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($result))
{
echo $row['name'];
echo "<br>";
}
?>
答案 1 :(得分:0)
试试这个: -
Select distinct name from testing;