假如有三个表a,b,c,现想动态的创建一表TempTable。
然后分别从abc表中取出一定的随机记录添加到TempTable中。
(表abc字段相同)
在线等待!望高手赐教!!

解决方案 »

  1.   

    数据库名为data,可以将TempTable建在data数据库中
      

  2.   

    drop table temptable
    select * into temptable from a where 随机条件
    insert into temptable select * from b where 随机条件  
    insert into temptable select * from c where 随机条件
      

  3.   

    先从adc 取记录,然后每一个表中取得的记录添加 到temptable 中即可
    用sql语句就似乎可以,我记得不大清楚了,似乎creat 什么的就创建一个表
      

  4.   

    SQL SERVER里有临时表就是表前加# 例如 表 #TABLE 就是一个临时表得写法
      

  5.   

    select * from a where 随机条件
    untion select * from b where 随机条件
    untion select * from c where 随机条件
    into kkk
      

  6.   

    drop table temptable
    select * into temptable from a where 随机条件
    insert into temptable select * from b where 随机条件  
    insert into temptable select * from c where 随机条件
      

  7.   

    create table TempTable
    insert into TempTable select * from a where 随机条件
    insert into TempTable select * from b where 随机条件
    insert into TempTable select * from c where 随机条件随机条件好像可以用rand()之类的函数取。
      

  8.   

    可不可以写一下随机的记录怎么求啊?
    数据库为Access
    建表只要一条Create语句就行啦??
      

  9.   

    create table tempt(
      a char(10) not null
      .
      .
      .
    )//创建表tempt 字段ainsert into TempT select  top 2 * from a where 随机条件
    insert into TempT select top 2 * from b where 随机条件
    insert into TempT select top 2 * from c where 随机条件
      

  10.   

    写一个随机函数倒是没问题,可Where后面的随机条件怎么写?
    请赐教啊!!
      

  11.   

    DS1, select * from A
    DS2, select * from B
    DS3, select * from C
    假设你的三个表中各有5000个记录
    i := 0
    j := 0
    i := Random(100)
    while (i > 0) and (not DS1.eof) do
    begin
      i := i - 1
      DS1.next
    end;
    读取一条记录
    if not DS1.eof then
    begin
     ....
    end;
    i := Random(100)
    while (i > 0) and (not DS2.eof) do
    begin
      i := i - 1
      DS2.next
    end;
    读取一条记录
    if not DS2.eof then
    begin
     ....
    end;
    i := Random(100)
    while (i > 0) and (not DS3.eof) do
    begin
      i := i - 1
      DS3.next
    end;
    读取一条记录
    if not DS3.eof then
    begin
     ....
    end;
      

  12.   

    请问楼主,这个问题的实际意义是什么?好像在这个里面我只看到Random有点用以外,你的问题在实际中是用来做什么的?
      

  13.   

    insert into temptable 
    select * from a where 某字段=newid() //newid() 随机函数。
    union all
    select * from b where 某字段=newid() //newid() 随机函数。
    union all
    select * from c where 某字段=newid() //newid() 随机函数。
      

  14.   

    在表中增加一个字段No,为自增变量,则其值与行号相同(不删除记录的情况下)
    然后,如果你想随机取10条记录,则在客户端用random(5000)[假设有5000条记录]的方式生成10个随机数,然后
    select * from A where No in (a1,a2,...,a10)
    union
    select * from B where No in (b1,b2,...,b10)
    union
    select * from C where No in (c1,c2,...,c10)
    (其中a1..a10,b1..b10,c1..c10)是30个随机数
      

  15.   

    select * ##TempTable from a where 条件
    Union
    Select * from b where 条件
    union
    select * from c where 条件