lmpearce1
lmpearce1

Reputation: 179

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:

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?

Thanks

Upvotes: 0

Views: 152

Answers (3)

Damir Bulic
Damir Bulic

Reputation: 2249

MySQL does not allow to create temporary tables on the fly. 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.

Upvotes: 0

Devart
Devart

Reputation: 121952

You should use INSERT ... SELECT statement instead of SELECT with INTO.

Upvotes: 2

KodeFor.Me
KodeFor.Me

Reputation: 13511

I think that is

INTO "tablename"

Upvotes: 0

Related Questions