distal-attribute
distal-attribute
distal-attribute
distal-attribute

Syntax for Creating Temporary Table

JDizzler posted 5 months ago in General
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 posted 5 months ago
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.
JDizzler posted 5 months ago
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.