一张数据表只有2个字段staff_num和fleet_cd,下面是3条事例数据
staff_num   fleet_cd
10001       p65
10002       p67
10001       p67要求,查找出fleet_cd等于p65又等于p67的用户,谢谢

解决方案 »

  1.   

    select * from table where fleet_cd = p65 and fleet_cd=p67
    不过你实例数据里好像没这样的记录
      

  2.   

    staff_num是用户id?
    是否是找出fleet_cd中有p65也有p67的staff_numselect distinct staff_num from table1 a
      where fleet_cd='p65'
        and exists(select 1 from table1
          where staff_num=a.staff_num and fleet_cd='p67')
      

  3.   

    要求,查找出fleet_cd等于p65等于p67的用户???--会出数据吗?会有数据出来才怪呢?这个条件永远不成立啊?
      

  4.   

    --莫非楼主的意思是:staff_num字段相等,但其 fleet_cd等于p65 又等于p67的用户???
    --有这两个数据行存在就行?--是 staff_num字段相等,但fleet_cd 等于p65 又等于p67 的有且只有两条记录??
    --是这个意思吗?