开发者

How to save select query results within temporary table?

开发者 https://www.devze.com 2023-01-30 03:05 出处:网络
I need to save select query output into temporary table. Then I need to make another select query against this temporary table. Does anybody know how to do it?

I need to save select query output into temporary table. Then I need to make another select query against this temporary table. Does anybody know how to do it?

I need to mak开发者_StackOverflowe this on SQL Server.


select *
into #TempTable
from SomeTale

select *
from #TempTable


You can also do the following:

CREATE TABLE #TEMPTABLE
(
    Column1 type1,
    Column2 type2,
    Column3 type3
)

INSERT INTO #TEMPTABLE
SELECT ...

SELECT *
FROM #TEMPTABLE ...

DROP TABLE #TEMPTABLE


In Sqlite:

CREATE TABLE T AS
SELECT * FROM ...;
-- Use temporary table `T`
DROP TABLE T;
0

精彩评论

暂无评论...
验证码 换一张
取 消