本帖最后由 huayy 于 2011-12-12 09:53:35 编辑

解决方案 »

  1.   

    select * from table where a_user = '涛涛' and a_integral = 100你想要实现什么啊?说清楚点
      

  2.   

    你用的什么数据库?数据库不同,sql语句不同的
      

  3.   

    我们用的是Oracle
    select a.* from table a,table b where a.a_user = b.a_user  and a.a_integral = b.a_integral 
    试试这个,刚才那个是没吕清楚
      

  4.   

    额,抱歉,是mssql 数据库。。
      

  5.   

    mysql应该也可以给表起别名,你先试试我给你的第二条可以用不,不行我给你现查书
      

  6.   

    select * from tb a
    where exists(select 1 from tb where a_user=a.a_user and id<>a.id)
      

  7.   

    表结构ID  a_user  a_title   a_integral
    1   涛涛   购买商品XXX获得积分   100
    2   宝宝   购买商品CCC获得积分   50
    3   平平   购买商品DDD获得积分   60
    4   涛涛   购买商品TTT获得积分   100
    实现下面的显示
    ID  a_user  a_title   a_integral
    1   涛涛   购买商品XXX获得积分   100
    4   涛涛   购买商品TTT获得积分   100即a_user相同、且a_integral相同的两条或以上的数据. 
      

  8.   

    可以使用T_sql 的交集   Intersect 
    select * from a_user
    Intersect 
    select * from a_integral你试试  如果还有语法的问题  你可以看看帮助文档  但是用Intersect  是可以实现你的需求的
      

  9.   


    select* from table1 a where (select count(1) from table1 where a_user= a.a_user and a_integral = a.a_integral)
      

  10.   

    用distinct 语句可以过滤出来相同的 
      

  11.   


    select a_user ,a_integral from  table group by a_user ,a_integral having count(a_user)>1 and count(a_integral)>1
      

  12.   

     忘记写判断条件了、、、
    select*   from   table1   a   where   (select   count(1)   from   table1   where   a_user=   a.a_user   and   a_integral   =   a.a_integral) >1
      

  13.   

    或者这样效率高一点,如果ID是主键的话,select * from table1 a where not exists
    (select 1 from table1 where id<>a.id and   a_user=   a.a_user   and   a_integral =a.a_integral)
      

  14.   

     把 not 去掉,写错了
      

  15.   

    select * from tbName a
    where exists(select 1 from tbName where a_user=a.a_user and a_integral =a.a_integral  and id<>a.id)