如何查询使组合列不重复,如(姓名+年龄)组合起来不重复,而单列上(如:姓名)可重复

解决方案 »

  1.   

    表结构是什么样的?你要达到什么功能?
    group by ?
      

  2.   

    select distinct 姓名,年龄 from table1
      

  3.   

    select tb.* from tb,
    (select name,age from tb group by name,age) tt
    where tb.name=tt.name and tb.age=tt.age
      

  4.   


    select a.* from tablename a where
    exists (select * from tablename b where a.name||a.age!=b.name||b.age)