distinct使SQL查询除去重复的字段
sql语句去重,distict的用法:
select distinct 字段名 from [表名]
Sql = "Select * from (Select max(可输入顺序的字段) as indexfield,要去重复字段名 From 数据表 Where 条件 Group by 要去重复字段名) as A Where 条件 order by A.indexfield "
例子:
select distinct(orderno),keye,key1,addtime,dtype,consignee,address,bank,tel,email,yb,invoice,content,uid from indent where keye=0 order by id desc
《一棵树-博客园》 收集整理,转载请注明出处!