日期:2014-05-19  浏览次数:20607 次

數據庫數據顯示問題
現在有一個   數據庫內容是
A  
A
B
B
C
C
我現在就想顯示里面沒有重復的數據
A
B
C
怎么用SQL語法實現?

------解决方案--------------------
Select Distinct 字段 From 表
------解决方案--------------------
select distinct 字段 from 表.
------解决方案--------------------
Select 字段 From 表 Group By 字段
------解决方案--------------------
--------------例子--------
create table A(name varchar(10),scot int)
insert A
select 'a ',1 union all
select 'b ',1 union all
select 'c ',1 union all
select 'd ',2 union all
select 'e ',2

1。
select min(name),scot from a group by scot ---第一种方法

2。
select
t.*
from
a t
where
not exists(select 1 from a where name <t.name and scot=t.scot) ---第二种方法