Home > Database > Mysql Tutorial > sql如何去除重复数据

sql如何去除重复数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:46:59
Original
1775 people have browsed it

sql如何去除重复数据,

很多朋友一听就会想到DISTINCT ,那我们来看看distinct的用法吧.

下面来看看语法:

SELECT DISTINCT column_name(s)FROM table_name
Copy after login
下面看个简单的例子:
Copy after login
<pre class="brush:php;toolbar:false">SELECT DISTINCT City FROM Persons
Copy after login
 
Copy after login
Copy after login
Copy after login
好了下面我们再来看看另一种方法用group by 来做吧,这个想法是从网上来的下面我们来看看下面的sql.
Copy after login
 
Copy after login
Copy after login
Copy after login
Select *,m_id from tbname group by m_id order by w_support desc
Copy after login
 
Copy after login
Copy after login
Copy after login
本站原创:转载注明
Copy after login
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