그래서 내가 뭘 하려는지 스포츠 애플 리케이션 (특히 축구)에 대한 웹 응용 프로그램을 빌드하는 것입니다. 지금은 경기 점수가 기록 된 후 순위표를 업데이트해야하는 방아쇠에 문제가 있습니다. 이 예에서는 '게임'테이블과 '순위'테이블이 있습니다. 시간 /의 ATID (및 TID), FID, SID, 뚜껑은 각각 외국 팀에 키, 필드, 시즌과 리그 테이블입니다트리거에 오류 1054 (42S22)
mysql> describe game;
+-----------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------+------+-----+---------+-------+
| sid | int(11) | NO | PRI | NULL | |
| fid | int(11) | NO | PRI | NULL | |
| lid | int(11) | NO | PRI | NULL | |
| htid | int(11) | NO | PRI | NULL | |
| atid | int(11) | NO | PRI | NULL | |
| date | date | NO | | NULL | |
| time | time | NO | | NULL | |
| h_g | int(11) | NO | | 0 | |
| a_g | int(11) | NO | | 0 | |
| has_been_played | tinyint(1) | NO | | 0 | |
+-----------------+------------+------+-----+---------+-------+
10 rows in set (0.00 sec)
mysql> describe standings;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| tid | int(11) | NO | PRI | NULL | |
| sid | int(11) | NO | PRI | NULL | |
| lid | int(11) | NO | PRI | NULL | |
| pld | int(11) | NO | | 0 | |
| pts | int(11) | NO | | 0 | |
| h_w | int(11) | NO | | 0 | |
| h_t | int(11) | NO | | 0 | |
| h_l | int(11) | NO | | 0 | |
| h_gf | int(11) | NO | | 0 | |
| h_ga | int(11) | NO | | 0 | |
| a_w | int(11) | NO | | 0 | |
| a_t | int(11) | NO | | 0 | |
| a_l | int(11) | NO | | 0 | |
| a_gf | int(11) | NO | | 0 | |
| a_ga | int(11) | NO | | 0 | |
+-------+---------+------+-----+---------+-------+
15 rows in set (0.00 sec)
.
게임을 업데이트 한 후에 트리거를 만들고 싶습니다. 이 응용 프로그램에서 목표로하고있는 현재 디자인은 "게임"이 삽입 될 때 아직 "재생"되지 않았으며 업데이트 될 때 점수가 기록 된 다음 게임이 "재생 된"것으로 간주된다는 것입니다. 여기 트리거의 섹션이 있습니다.
그리고 이러한 이유로 나는 어떤 이유에서인지 확신 할 수 없습니다.
mysql> source new_trigger_myfam.sql
ERROR 1064 (42000): 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 '' at line 18
ERROR 1054 (42S22): Unknown column 'OLD.atid' in 'where clause'
ERROR 1064 (42000): 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 'ENDIF' at line 1
ERROR 1064 (42000): 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 'ENDIF' at line 1
ERROR 1064 (42000): 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 'END' at line 1
구문이 눈에 띄게 이상합니까? 나는 case/when/then을 사용하여 두 개의 update query를 할 수 있다는 것을 이해한다. 본질적으로, 트리거의 스 니펫에서는 이전 업데이트를 뒤집은 다음 실제로 나머지 업데이트를 수행하는 코드가 더 있습니다. 나는 트리거가 새롭기 때문에 항상 도움을받을 수 있습니다.
이상하게도 끝까지 생기면 그 줄이 아직도 나에게 짖는다. –