randomize()
rand()
在数据库中抽取’随机数‘道题(id自增),什么意思?

解决方案 »

  1.   

    是在数据库中用随机数还是在DELPHI中用随机数?
      

  2.   

    随即数,由random产生,但怎样抽题呢?
      

  3.   

    每一道题目都是有一个独立的ID
    而题目的总数(TotalQuestion)可以从 
    select count(id) from MyDataBase where ....得知
    跟着 Random(totalQuestion)+1 求随意题目var TotalQuestion, CurrentQuestion : Integer;.....Query1.sql.clear;
    Query1.sql.Add('select count(id) from AllQuestion');
    Query1.open;totalQuestion := query1.field[0].AsInteger;
    randomize;
    CurrentQuestion := Random(TotalQuestion)+1;Query2.sql.clear;
    query2.sql.Add('select field1,.... from AllQuestion';
    query2.sql.Add('where ID = :ID);
    query2.ParmByName('ID').AsInteger := CurrentQuesiton;
    Query2.open;
      

  4.   

    YourRecordCount:=select max(id) from YourTable;
    randomize();
    id:=random(YourRecordCount);
      

  5.   

    select top 1 * from TableName order by NewId()
    试一试,还好用