简体   繁体   English

存储过程SQL转换为MySQL

[英]Stored Procedure SQL Conversion to MySQL

I have this chunk of SQL from a stored procedure and i can convert almost all of it, except for the 'INTO #t1' line which i believe is a temporary table: 我从存储过程中获得了这一块SQL,我可以转换几乎所有的SQL,除了'INTO#t1'行,我相信它是一个临时表:

SELECT siteid, MIN(Eload) + dbo.GetOffset(siteid, 'Eload', MIN(time)) AS Eload

INTO #t1

FROM calcdata WITH (NOLOCK)

WHERE siteid IN (SELECT siteid FROM community_site WHERE communityid = @communityid)

AND time between @start AND @finish

AND Eload < 1000000

AND Eload <> 0

GROUP BY siteid

What is the MySQL equivalent of the INTO #t1 line? 什么是INTO#t1系列的MySQL等价物?

Thanks 谢谢

您应该使用INSERT ... SELECT语句而不是SELECT INTO。

MySQL does not allow to create temporary tables on the fly. MySQL不允许动态创建临时表。 You can create temporary table explicitly (see reference ), but you are generally better off with simply creating normal table and dropping it after you are done with it. 您可以显式创建临时表(请参阅参考资料 ),但通常只需创建普通表并在完成后将其删除即可。 If you were to create it explicitly and fill, you need to know all fields in advance, which could be cumbersome. 如果你要明确地创建它并填充,你需要提前知道所有字段,这可能很麻烦。

我想是的

INTO "tablename"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM