query($sql); $l=''; while($c="/> query($sql); $l=''; while($c=">
Home > Backend Development > PHP Tutorial > 除了重复的数据

除了重复的数据

WBOY
Release: 2016-06-13 12:43:16
Original
883 people have browsed it

去除重复的数据。

<br />
//查询A表最新添加的文章<br />
$sql="select id,biaoti,neirong from a order by id desc limit 15";<br />
$c=$mysqli->query($sql);<br />
$l='';<br />
while($c=$csql->fetch_assoc()){<br />
        $l.=$c['biaoti'].'--'.$c['id'].'--'$c['neirong'].'<br>';<br />
    }<br />
Copy after login


很简单,以上就是把最新添加的文字按ID倒序排序!

求解: 如 列出的15条记录中,其中 biaoti 会有出现重复的问题 如下

标题biaoti  内容neirong  id
香港新闻      特特          15
国际新闻      郭德纲        14
国际新闻       郭德纲的     13
国际新闻       退热贴       12
国内新闻         成功典范   11
广东新闻     郭德纲儿太热   10
广西新闻        二套二厅    9
上海新闻        二套二厅    8

从上边的列表看来,国际新闻重复出现3次了。有没办法,去掉2条,保留一条。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template