我是sql新手,所以也许这是一个愚蠢的问题,但它能吗?With子句与Insert Into一起使用?还是有什么常见的解决方案?我的意思是:4 C3 x, F+ H% G
With helper_table As (Select * From dummy2)Insert Into dummy1 Values (Select t.a From helper_table t Where t.a = 'X' );谢谢!( `( s: {( K, W- J
我的例子太虚构了,所以我添加了一些扩展代码(到目前为止,答案是thx)。& j2 V8 @, s8 |7 X) p
INSERTINTO dummy values (a,b) //more valuesWITH helper_table AS SELECT * FROM dummy2 )WITH helper_table2 AS //from more tables SELECT * FROM dummy3 SELECT t.value as a,t2.value as bFROM helper_table t join helper_table t2 on t.value = t2.value //some joinWHERE t.value = 'X' and t2.value = 'X other stuff , @0 K a- r( W& }( q解决方案: " K; N# R( J6 b) p& _2 L! x
可根据需要使用多个 helper_tables”。 ! Z4 r& _# q3 s [6 e7 t+ e; kcreate table t(helper1 varchar2(50) ,helper2 varchar2(50) ,dataElement varchar2(50) );insert into t(helper1,helper2,dataelement)with de as(select level lvl from dual connect by level 考虑到这一点,您可以通过将表正常连接到主表来完成所有连接