Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我在一个 mysql 表中有三个表。
Table1 = number1 Table2 = number2 Table3 = number3
现在我想获得这些的所有可能组合,并希望将其保存在一个新表 allnumbers 中。如何做这样的事情?
使用UNION或UNION ALL:
UNION
UNION ALL
SELECT number1 FROM table1 UNION ALL SELECT number2 FROM table2 UNION ALL SELECT number3 FROM table3
如果要从此结果集中创建一个新表:
CREATE TABLE NewTable AS SELECT ... ...