--b,c字段相同的
select * from 表 a
where exists(select * from 表 where b=a.b and c=a.c and a<>a.a)

解决方案 »

  1.   

    --测试--测试数据
    create table tb(a int,b varchar(10),c int,d varchar(10))
    insert tb select 1,'张三','25','人事部'
    union all select 2,'张三','25','财务部'
    union all select 3,'李四','23','人事部'
    union all select 4,'张三','24','工程部'
    go--查询
    select * from tb a
    where exists(select * from tb where b=a.b and c=a.c and a<>a.a)
    go--删除测试
    drop table tb/*--测试结果a           b          c           d          
    ----------- ---------- ----------- ---------- 
    1           张三         25          人事部
    2           张三         25          财务部(所影响的行数为 2 行)
    --*/
      

  2.   

    select * from t_goods
    where exists(select * from t_goods where itemname=t_goods.itemname  and itemspec=t_goods.itemspec and itemno<>t_goods.itemno)这是我按你教我的写的,可以查不出来啊。
      

  3.   

    select * from t_goods a
    where exists(select * from t_goods where itemname=a.itemname  and itemspec=a.itemspec and itemno<>a.itemno)
      

  4.   

    老大,还是老大,我马上给分。
    以后还要请你多帮帮忙。刚学SQL没有多久。
      

  5.   

    [AS] table_aliastable_name、view_name 或 rowset_function 的别名,为方便起见而使用,或用于区分自联接或子查询中的表或视图。别名通常是一个缩短了的表名,用于在联接中引用表中的特定列。如果联接中的多个表中有相同名称的列存在,SQL Server 要求必须使用表名或别名来限定列名。(如果定义了别名则不能使用表名)。