我有一个自动递增的id表。该ID也是另一个表中的外键。当我尝试将值添加到这些表我得到一个异常 - 列数并不在行1存储过程自动增量 - 列计数异常
匹配值计数这些都是我的表:
CREATE TABLE Hotspot(
num int auto_increment not null,
id varchar(255),
x int,
y int,
width int,
height int,
UNIQUE(id),
PRIMARY KEY (num)
);
CREATE TABLE Hotspot_Label(
num int auto_increment not null,
question_id varchar(255),
hotspot_id varchar(255),
label_id varchar(255),
PRIMARY KEY (num),
FOREIGN KEY (hotspot_id)
REFERENCES Hotspot(id),
FOREIGN KEY (label_id)
REFERENCES Label(id),
FOREIGN KEY (question_id)
REFERENCES Question(id)
);
这是的一个存储过程表
PROCEDURE `insertHotspot`(IN recID varchar(255), x int, y int, width int, height int)
BEGIN
INSERT INTO Hotspot VALUES(recID, x, y, width, height);
END
我已阅读,你不需要在存储过程中插入一个自动增量值,所以我看不出什么错
这是我考虑在插入表名后忽略可选字段列表的一个不好的做法之一。 – Uueerdo