有两个表:申请表 A, 字段是 id ,content ,state(审核级别);审核表 B ,字段是 id ,aId(申请表id), UserId(审核人id), ApproveDate(审核日期)。
问题是如何判断当一位副总审核完了后给另一个副总审核。
比如张三李四都是副总,张三审核完了级别由3变成4,然后李四根据级别为4来取记录,但是如何排除张三也把4这条记录取出来,因为他已经审核过了。

解决方案 »

  1.   

    能不能根据最后审核人来排除,比如张三已经审核过了,那么最后审核的是张三,下次再取的时候就排除这条记录,不知道sql怎么去写
      

  2.   

    select * from A t
    where not exists (select 1 from B where aid=t.id and UserId='登录人id')
      

  3.   

    A:
     id ,content ,state
      1    aaa       3
      2     b       4
      3     c       4B:
    id ,aId, UserId  ApproveDate
     1    1     王五   2008-9-19 15:09:57
     2    2     王五   2008-9-19 15:10:57
     3    2     张三   2008-9-19 15:12:57
     4    3     王五   2008-9-19 15:8:57
     4     3     李四   2008-9-19 15:11:57张三和李四都可以取state为3和4的数据,关键是取4的时候如何筛选的问题,我构造了上面的数据,大家帮我看看
      

  4.   


    select * from A t
    where not exists (select 1 from B where aid=t.id and UserId='登录人id')小雄的这个也不行,因为还有审核不通过的情况存在,我只想要判断最后一个审核人不是登陆人就可以了