我在SQL中作了判断,但是不知道怎么做循环遍历所有记录,如何在循环中做判断啊?

解决方案 »

  1.   

    insert into 新表
    select 编号,case when A表姓名<>B表姓名 then '姓名不同' 
        case when A表时间<>B表时间 then '时间不同' end,
        case when A表姓名<>B表姓名 then A表姓名 
        case when A表时间<>B表时间 then A表时间 end
    from 表F
      

  2.   

    其实可以分2步来做。1先建1张表 select * from a,b where a.a1<>b.b1 and a.a2<>b.b2.....
     2,再来建1新表,专门用来分类 用一循环对上表中的数据进行比较,将不同的数据写入新表中即可