我的access数据库里面数据是这样的,比如
  
  字段
  country  servername  channel 
  USA      T-2k          1
  USA      T-2K          2
  USA      T-2k          3  我想根据国家去除servername中数据,只显示一行,该怎么做?
  
  比如查询到usa 那么就增加一行T-2K combobox1.item.text上就行了。
  
  用select distinct 字段 from 表名 不行!

解决方案 »

  1.   

    试试用
    select country , servername group by country , servername 
      

  2.   

    不好意思,少写from 
    select country , servername from 你的表 group by country , servername 
      

  3.   

    'select * from serverinfo where Country ='''+combobox1.Text+''''
    我是这样查询的,但根据国家 读取到servername 是重复的。我给你们看数据库吧!country servername channel IP1 port1 IP2 port2
    DE 1-12 C1
    DE 1-12 C2
    DE 1-12 C3
      

  4.   

    select distinct 字段 from 表名 group by 字段
      

  5.   

    楼上你给的SQL语句不行啊。不满足我的要求
      

  6.   

    'select distinct country,servername from serverinfo where Country ='''+combobox1.Text+'''' 你如果是
    'select distinct * from serverinfo where Country ='''+combobox1.Text+'''' 
    肯定不行啦。
      

  7.   

    如果你只要得到某个country的servername,这样就可以了
    select  distinct servername  from serverinfo where Country ='DE'
    (因为Country是已知的了)
      

  8.   

    distinct country,servername 
      

  9.   

    说实话,不知道你想表达什么,distinct 只针对大型字段不行,其它都行的。怎么到你那里就不行了,还是的需求根本就不是你所表述的。
      

  10.   

    雖然不太明白樓主的意思 但是可以使用Having ('')=1 試試  也許可以