咱样才能从一个数据表(student)中随机的抽取出20条记录,并且每一次抽取的时候能保证不重复?help me!help me!

解决方案 »

  1.   

    取出ID,写如数组,随机函数,纪录ID,提取数据
      

  2.   

    如是不写函数,可不可以直接用sql语句来实现?
      

  3.   

    var
      stutid:integer;
      i: integer;begin
      for i:=0 to 19 do
      begin
        Randomize;
        stuid:=random(最大的学生id);
        query1.sql.clear;
        query1.sql.add('select * from student where studentid=:stuid')
        //
        将取出来的记录做处理;
        //
      end;
    end;
      

  4.   

    Randomize() can't ensure distinct.if you execute 'select 'again and again
    every method can't ensure distinct too,
    beacause the recordcount of the table is limited.
      

  5.   

    Randomize() can't ensures distinct.if you execute SQL statement 'select... 'again and again
    any method can't ensures distinct result too,
    beacause the recordcount of the table is limited.
      

  6.   

    hehe,看不懂英文~~上面我写的只是个雏形,不完整,但是很确定是可行的,自己考虑完善好了