为什么要查出后再删除?为什么不用select distinct(ZGBH) from table来去掉重复的记录?
(ZGBH为表中的一个字段。)

解决方案 »

  1.   

    dinstict加上去即可。不同的才出现。
      

  2.   

    如果你的目的是整理表(删除重复)的话,可以这样:
    while true do
    begin
        with query1 do
        begin
            close;
            sql.clear;
            sql.add('select * from 表名 group by 字段 having count(*)>1');
            open;        if recordcount=0 then break;        first;
            while not eof do
            begin
                delete;
                next;
            end;
        end;
    end;
                  
       
      

  3.   

    建一个临时表,先insert into加dinstict的select 语句先将不重复的记录倒入临时表,清空原表,再倒回来
      

  4.   

    Select Distinct 字段 From 表~~就可以了~~
    Distinct就是去处相同行~~