表名 (table)
字段  (userid  siteno)
数据1  178     9063
数据2  178     9063
问题是,我如果写查询语句只显示一条数据

解决方案 »

  1.   

    把你的SQL 贴出来
    你是要查询 userid =178 siteno =9063的数据?
    select 你要显示的字段 from table where userid =178 and siteno =9063
      

  2.   

    select DISTINCT amount from checks 查看不重复的数select amount from checks 查看重复的数
      

  3.   


    select DISTINCT  字段 from 表名.
    这样是不行的
      

  4.   

    select  DISTINCT bf_user.userid,st_site.siteno,st_power.powerid,bf_user.usertruthname from st_site,bf_user,st_power where (bf_user.userid = st_power.userid and st_power.siteno=st_site.siteno) and st_site.siteno = 6022 and bf_user.usertruthname = '徐旭' ;
    这样还是能出现重复的
      

  5.   

    你用的是什么数据库?select DISTINCT userid,siteno from table会将userid 和 siteno 两个都相同的数据才过滤的如果是mysql就不能用这个方法!
      

  6.   

    加上group by userid,siteno
      

  7.   

    select distinct(userid), siteno from table
    这样就行了吧, 将需要唯一的字段写到distinct里面, 其他的不变