从两个现有表创建一个新表,每种组合可能性 [英] Creating a new table from two existing tables with every combination possibility

查看:23
本文介绍了从两个现有表创建一个新表,每种组合可能性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个临时表 #a 和 #b,它们都填充了整数值.假设它们都包含 10 行,值为 1-10.

I have two temporary tables #a and #b both filled with integer values. Let's say they both contain 10 rows with values 1-10.

我想创建第三个临时表 #c,其中包含 a 和 b 的所有可能组合.所以它总共有 100 行 (1,1), (1,2) ... (10, 10).我将如何在 SQL 中执行此操作.我使用的实现是 SQL Server 2012.

I want to create a third temporary table #c that contains every possible combination of a and b. So it would have 100 rows total with (1,1), (1,2) ... (10, 10). How would I go about doing this in SQL. The implementation I'm using is SQL Server 2012.

推荐答案

认为你可以做到

SELECT * INTO #c FROM #a,#b

这篇关于从两个现有表创建一个新表,每种组合可能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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