1

我的第一个 MySQL 程序有问题。我找不到语法错误。这是程序的主体:

DECLARE TerminId INT;

INSERT INTO `Termin` (`Beginn`, `Ende`, `Titel`, `Ganztaegig`, `Serie`, 
                      `Bemerkung`, `Tooltip`, `Ort`, `Gruppe`, `UserId`) 
VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, 
        BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

SET TerminId = ( SELECT Distinct Id FROM Termin 
                 where Beginn = BeginnPara 
                       and Ende = EndePara 
                       and UserId = UserIdPara);
4

2 回答 2

1

删除简单报价

  DECLARE TerminId INT;

    INSERT INTO Termin(Beginn, Ende, Titel, Ganztaegig, Serie, Bemerkung, Tooltip, Ort, Gruppe, UserId) VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

    SET TerminId= (SELECT Distinct Id FROM Termin where Beginn = BeginnPara and Ende = EndePara and UserId = UserIdPara having row_number <= 1);
于 2012-08-26T19:28:57.890 回答
0

尝试:

DECLARE TerminId INT;
INSERT INTO `Termin`(`Beginn`, `Ende`, `Titel`, `Ganztaegig`, `Serie`, `Bemerkung`, `Tooltip`, `Ort`, `Gruppe`, `UserId`) VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

SELECT Distinct Id INTO TerminId FROM Termin where Beginn = BeginnPara and Ende = EndePara and UserId = UserIdPara having row_number <= 1);

问候。

于 2012-12-05T05:38:47.113 回答