select distinct columna, columnb from yourtable where ....

解决方案 »

  1.   

    应该是用 distinct 对这两列操作后,使这两列的组合相当于主键的功能
      

  2.   

    select distinct col1, col2 from yourtable
      

  3.   

    把所有不唯一的组合查出来
    select col1,col2 from test group by col1,col2 having count(*) >1
    把所有不唯一的组合删除
    delete from test where exists select 1 from test group by col1,col2 having count(*) >1
      

  4.   

    把所有不唯一的组合查出来
    select col1,col2 from test group by col1,col2 having count(*) >1
    把所有不唯一的组合删除
    delete from test where exists select 1 from test group by col1,col2 having count(*) >1
      

  5.   

    如果用 select distinct col1,col2,col3......后面还有其他列时,distinct 对哪几列进行操作。如果我有如下记录
        
        col1     col2         col3     col4    ......   dddddd     3            1       t
       ffffff     2            2       f
       rrrrrr     2            2       g
       tttttt     3            2       h
    以 col2 和 col3 用distinct 形成具有主键功能的组合键
    具体怎么写 SQL 语句
      

  6.   

    1.distinct影响其后面的所有列出的列;
    2.select distinct col2,col3 from tab
      

  7.   

    那我如果只想对两列起作用,但又想一次 select 多列怎办
      

  8.   

    select col2,col3,min(col4),min(col5)
    from tab
    group by col2,col3