Syntax for Creating Temporary Table

[expired user #8118]'s profile image [expired user #8118] posted 10 years ago in General Permalink
I am trying to create a temporary table to get some data from other tables.
CREATE TABLE #temps 
(
id	int,
agentCnt	int,
serviceTeamCnt	int
PRIMARY KEY (id)
)

The error I'm getting is

/* SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(
VId int,
id int,
agentCnt int,
serviceTeamCnt int

' at line 2 */

Does heidi not create temporary tables using this syntax? If not what could you suggest? I'm a big noob at this so any help would be greatly appreciated

jfalch's profile image jfalch posted 10 years ago Permalink
a) non-alphanum tabel name must be quoted (ie `#temps`)
b) there must be a comma after last field def

CREATE TABLE `#temps` (
id int(11),
agentCnt int,
serviceTeamCnt int,

PRIMARY KEY (id)
)

works on my server.
[expired user #8118]'s profile image [expired user #8118] posted 10 years ago Permalink
Yeah that works great thanks. and I found another way just now.
It also works using this syntax

CREATE TEMPORARY TABLE temps
(
id int,
agentCnt int,
serviceTeamCnt int,
)

Also thanks for the a and b tips. It helps a lot

Please login to leave a reply, or register at first.