很简单的数据库的问题 (50分)

  • 主题发起人 主题发起人 我要上
  • 开始时间 开始时间

我要上

Unregistered / Unconfirmed
GUEST, unregistred user!
表中“车号”字段是可重复的,我想让
‘车号’字段唯一显示,并且其它字段也能显示,
用select distinct 车号 from table 只能显示“车号”,
用select distinct 车号,id,name from table 提示错误
(1)请问,我该怎么写
(2)如何在服务器端得知车号有重复的
 
提示什么错误?
你想车号唯一,就只能用select distinct 车号 from table
如果你用select distinct 车号,name from table
那就就是车号和name 唯一
 
你的表必须有主键
假设 id 为主键, int
当车号相同,显示id最小的
select * from table where id in (select min(id) from table group by 车号)
 
select * from table where id in
(select distinct(id) from table )
 
没人理吗
 
select * from tablename
group by 车号
 
如何在服务器端得知车号有重复的?????
 
采有select Count(車號) from table
和 select count(distinct(車號)) from table
 
多人接受答案了。
 
后退
顶部