使 SQL 多次选择同一行 [英] Make SQL Select same row multiple times

查看:31
本文介绍了使 SQL 多次选择同一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试我的邮件服务器.我怎样才能做一个 Select 语句选择说 ID=5469 一千次.

I need to test my mail server. How can I make a Select statement that selects say ID=5469 a thousand times.

推荐答案

如果我明白你的意思,那么一个非常简单的方法是交叉联接一个表的派生查询,该表中的行超过 1000 行,并放置前 1000在那.这会将您的结果重复 1000 次.

If I get your meaning then a very simple way is to cross join on a derived query on a table with more than 1000 rows in it and put a top 1000 on that. This would duplicate your results 1000 times.

举个例子(这是MSSQL,我不知道Access是否有很大不同)

As an example (This is MSSQL, I don't know if Access is much different)

SELECT
    MyTable.*
FROM
    MyTable
CROSS JOIN
(
    SELECT TOP 1000
        *
    FROM
        sysobjects
) [BigTable]
WHERE
    MyTable.ID = 1234

这篇关于使 SQL 多次选择同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆