我不确定为什么以下查询不起作用
INSERT INTO Cricket_fixture
('season_id', 'league_id', 'fixdate', 'team_one_id', 'team_two_id')
VALUES ('1', '1', '2012-05-13', '8', '3')
我已经尝试过:
- 基于搜索的各种日期格式 2012-05-13、2012/05/13、20120513(带引号和不带引号);
- 还确保满足 FK 关系,因为前两列是 FK,但两者都存在值“1”并且有效。
我不断收到错误:
#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 ''season_id', 'league_id', 'fixdate', 'team_one_id', 'team_two_id') VALUES ('1', ' at line 1
已解决 - 问题是我对列名称使用单引号(仅适用于值)
最佳答案
您不需要在列名称上使用单引号。您可能会使用反引号,但我从不这样做。
INSERT INTO Cricket_fixture (season_id, league_id, fixdate, team_one_id, team_two_id) VALUES ('1', '1', '2012-05-13', '8', '3')
关于mysql - 通过 phpMyAdmin SQL 控制台插入日期失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10452860/