Distinct:
去掉重复记录.
所有显示出的(可以不用* ,加字段显示)字段的值都相同才会显示其中一条。
语法:
Select distinct * from tbl_name;
* (可以换成字段名称来显示某一些字段)
与之对应的是 all,表示所有,默认值
/*简单示例*/
use php_one;
create table t12(
a int
);
insert into t12 values(5);
insert into t12 values(10);
insert into t12 values(1);
insert into t12 values(15);
insert into t12 values(7);
insert into t12 values(8);
insert into t12 values(15);
insert into t12 values(50);
insert into t12 values(3);
insert into t12 values(1);
insert into t12 values(50);
insert into t12 values(35);
select * from t12;
select * from t12 order by a;
select distinct * from t12 order by a ; /*消去重复的*/