请帮忙 我有下面的触发代码
DELIMITER $$
CREATE TRIGGER `mydb`.`table0`
AFTER INSERT ON `mydb`.`table0`
FOR EACH ROW
BEGIN
IF (
SELECT table1.idtable1 FROM table2, table1, table
WHERE table1.idtable1=table2.idtable2
and table0.idtable0=table1.idtable1
)
THEN
UPDATE targettable
SET targettable.column = 1
WHERE targettable.idtable=table1.idtable1;
END IF;
END$$
运行后,显示错误
如何解决? MySQL版本是5.5.34
答案 0 :(得分:1)
表是mysql中的保留字。带反叛的环绕桌。你也错过了分隔符和末尾的分号。 这有效:
#include <iostream>
#include <array>
int main() {
constexpr size_t a=5;
constexpr size_t b=4;
constexpr size_t c=3;
std::array<std::array<std::array<float,a>, b>, c> arr3d;
for(auto& outer : arr3d){
for(auto& row : outer){
for(auto& place : row){
place=3.5;
}
}
}
for(size_t i=0;i<a; ++i){
for(size_t j=0;j<b; ++j){
for(size_t k=0;k<c; ++k){
arr3d[i][j][k]=k; // or whatever
}
}
}
std::cout << arr3d[0][1][2] << std::endl;
}
我希望有所帮助!
答案 1 :(得分:1)
DELIMITER $$
CREATE TRIGGER `mydb`.`table0`
AFTER INSERT ON `mydb`.`table0`
FOR EACH ROW
BEGIN
IF (
SELECT table1.idtable1 FROM table2, table1, table <-- you should escape this using backticks as this is a reserved word i.e., `table`
WHERE table1.idtable1=table2.idtable2
and table0.idtable0=table1.idtable1
)
THEN
UPDATE targettable
SET targettable.column = 1
WHERE targettable.idtable=table1.idtable1;
END IF;
END$$