drop table temptable select * into temptable from a where 随机条件 insert into temptable select * from b where 随机条件 insert into temptable select * from c where 随机条件
select * from a where 随机条件 untion select * from b where 随机条件 untion select * from c where 随机条件 into kkk
drop table temptable select * into temptable from a where 随机条件 insert into temptable select * from b where 随机条件 insert into temptable select * from c where 随机条件
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()之类的函数取。
可不可以写一下随机的记录怎么求啊? 数据库为Access 建表只要一条Create语句就行啦??
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 随机条件
写一个随机函数倒是没问题,可Where后面的随机条件怎么写? 请赐教啊!!
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;
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() 随机函数。
在表中增加一个字段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个随机数
select * ##TempTable from a where 条件 Union Select * from b where 条件 union select * from c where 条件
select * into temptable from a where 随机条件
insert into temptable select * from b where 随机条件
insert into temptable select * from c where 随机条件
用sql语句就似乎可以,我记得不大清楚了,似乎creat 什么的就创建一个表
untion select * from b where 随机条件
untion select * from c where 随机条件
into kkk
select * into temptable from a where 随机条件
insert into temptable select * from b where 随机条件
insert into temptable select * from c where 随机条件
insert into TempTable select * from a where 随机条件
insert into TempTable select * from b where 随机条件
insert into TempTable select * from c where 随机条件随机条件好像可以用rand()之类的函数取。
数据库为Access
建表只要一条Create语句就行啦??
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 随机条件
请赐教啊!!
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;
select * from a where 某字段=newid() //newid() 随机函数。
union all
select * from b where 某字段=newid() //newid() 随机函数。
union all
select * from c where 某字段=newid() //newid() 随机函数。
然后,如果你想随机取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个随机数
Union
Select * from b where 条件
union
select * from c where 条件