数据库的SQL查询语句
来源:百度知道 编辑:UC知道 时间:2024/06/05 16:50:23
USE exam
GO
select CityCode
from distrbutors
where select distinct CityCode from distrbutors
我想实现有相同的数据只显示一次,而且还可以显示多个字段请问上面的语句有什么错没...???
GO
select CityCode
from distrbutors
where select distinct CityCode from distrbutors
我想实现有相同的数据只显示一次,而且还可以显示多个字段请问上面的语句有什么错没...???
distinct的位置放错了。
USE exam
GO
select distinct CityCode,[字段2,...n]
from distrbutors
where (你的条件写错了,可以补充一下条件试一试的)
肯定错了呀,条件写错
不用这样子写的
这样
select distinct * from distrbutors;
select * from distrbutors where CityCode in (select distinct CityCode from distrbutors)
不用那么费劲,下面的代码完全OK
select distinct CityCode
from distrbutors
select distinct CityCode from distrbutors
use exam
go
select distinct CityCode from distrbutors