这是我的SQL查询:
CREATE TABLE items(
id int(3) ,
name VARCHAR(255) ,
amount INT(4),
PRIMARY KEY (`id`)
);
-- BRONIE DO WALKI WRĘCZ
INSERT INTO items (id, name, amount) VALUES ('1', 'KATANA','0');
INSERT INTO items (id, name, amount) VALUES ('2', 'HATCHET','0');
INSERT INTO items (id, name, amount) VALUES ('3', 'TACTICAL KNIFE','0');
INSERT INTO items (id, name, amount) VALUES ('4', 'MACHETE','0');
-- PISTOLETY
INSERT INTO items (id, name, amount) VALUES ('5', '1911','0');
INSERT INTO items (id, name, amount) VALUES ('6', 'B92','0');
INSERT INTO items (id, name, amount) VALUES ('7', 'B93R','0');
INSERT INTO items (id, name, amount) VALUES ('8', 'DESERT EAGLE','0');
INSERT INTO items (id, name, amount) VALUES ('9', 'FN FIVESEVEN','0');
INSERT INTO items (id, name, amount) VALUES ('10', 'SIG SAUER P226','0');
INSERT INTO items (id, name, amount) VALUES ('11', 'STI Eagle Elite .45 ACP','0');
-- STRZELBY
INSERT INTO items (id, name, amount) VALUES ('12', 'AA-12','0');
INSERT INTO items (id, name, amount) VALUES ('13', 'KT DECIDER','0');
INSERT INTO items (id, name, amount) VALUES ('14', 'MOSSBERG 590','0');
INSERT INTO items (id, name, amount) VALUES ('15', 'SAIGA','0');
-- KARABINY SZTURMOWE
INSERT INTO items (id, name, amount) VALUES ('16', 'AK-74M','0');
INSERT INTO items (id, name, amount) VALUES ('17', 'AKM','0');
INSERT INTO items (id, name, amount) VALUES ('18', 'FN SCAR CQC','0');
INSERT INTO items (id, name, amount) VALUES ('19', 'FN SCAR NIGHT STALKER','0');
INSERT INTO items (id, name, amount) VALUES ('20', 'G36','0');
INSERT INTO items (id, name, amount) VALUES ('21', 'IMI TAR-21','0');
INSERT INTO items (id, name, amount) VALUES ('22', 'M16','0');
INSERT INTO items (id, name, amount) VALUES ('23', 'M4','0');
INSERT INTO items (id, name, amount) VALUES ('24', 'M4 Semi','0');
INSERT INTO items (id, name, amount) VALUES ('25', 'MASADA','0');
INSERT INTO items (id, name, amount) VALUES ('26', 'SIG SAUER 556','0');
-- KARABINY SNAJPERSKIE
INSERT INTO items (id, name, amount) VALUES ('27', 'BLASER R93','0');
INSERT INTO items (id, name, amount) VALUES ('28', 'M107','0');
INSERT INTO items (id, name, amount) VALUES ('29', 'MAUSER SP66','0');
INSERT INTO items (id, name, amount) VALUES ('30', 'MAUSER SRG DESERT','0');
INSERT INTO items (id, name, amount) VALUES ('31', 'SVD','0');
INSERT INTO items (id, name, amount) VALUES ('32', 'VSS VINTOREZ','0');
-- SUB MACHINE GUNY
INSERT INTO items (id, name, amount) VALUES ('33', 'BIZON','0');
INSERT INTO items (id, name, amount) VALUES ('34', 'EVO-3','0');
INSERT INTO items (id, name, amount) VALUES ('35', 'FN P90','0');
INSERT INTO items (id, name, amount) VALUES ('36', 'FN P90 S','0');
INSERT INTO items (id, name, amount) VALUES ('37', 'HONEY BADGER','0');
INSERT INTO items (id, name, amount) VALUES ('38', 'MP5/10','0');
INSERT INTO items (id, name, amount) VALUES ('39', 'MP7','0');
INSERT INTO items (id, name, amount) VALUES ('40', 'UZI','0');
INSERT INTO items (id, name, amount) VALUES ('41', 'VERESK SR-2','0');
-- LIGHT MACHINE GUNY
INSERT INTO items (id, name, amount) VALUES ('42', 'FN M249','0');
INSERT INTO items (id, name, amount) VALUES ('43', 'PKM','0');
INSERT INTO items (id, name, amount) VALUES ('44', 'RA H23','0');
INSERT INTO items (id, name, amount) VALUES ('45', 'RPK-74','0');
-- AMMO
-- ARROWS
INSERT INTO items (id, name, amount) VALUES ('46', 'ARROW', '0');
INSERT INTO items (id, name, amount) VALUES ('47', 'EXPLOSIVE ARROW', '0');
--HANDGUN AMMO
INSERT INTO items (id, name, amount) VALUES ('48', '9MM MAG', '0');
INSERT INTO items (id, name, amount) VALUES ('49', '.45 ACP STI EAGLE ELITE', '0');
INSERT INTO items (id, name, amount) VALUES ('50', '5.7 FN M240 MAG', '0');
INSERT INTO items (id, name, amount) VALUES ('51', 'DESERT EAGLE AMMO', '0');
INSERT INTO items (id, name, amount) VALUES ('52', '9X19 PARA MAG', '0');
--SHOTGUN AMMO
INSERT INTO items (id, name, amount) VALUES ('53', '2X 12 GAUGE', '0');
INSERT INTO items (id, name, amount) VALUES ('54', 'SHOTGUN SHELL 2X', '0');
INSERT INTO items (id, name, amount) VALUES ('55', 'SHOTGUN SHELL 8X', '0');
INSERT INTO items (id, name, amount) VALUES ('56', 'SAIGA 10', '0');
INSERT INTO items (id, name, amount) VALUES ('57', '12 GAUGE SLUG', '0');
INSERT INTO items (id, name, amount) VALUES ('58', 'AA-12 DRUM', '0');
--ASSAULT RIFLE AMMO
INSERT INTO items (id, name, amount) VALUES ('59', 'SG 30 ROUND', '0');
INSERT INTO items (id, name, amount) VALUES ('60', '5.45 AK 30', '0');
INSERT INTO items (id, name, amount) VALUES ('61', '5.45 AK 45', '0');
INSERT INTO items (id, name, amount) VALUES ('62', '5.45 AK DRUM', '0');
INSERT INTO items (id, name, amount) VALUES ('63', '7.62 AKM CLIP', '0');
INSERT INTO items (id, name, amount) VALUES ('64', 'STANAG 30', '0');
INSERT INTO items (id, name, amount) VALUES ('65', 'STANAG 45', '0');
INSERT INTO items (id, name, amount) VALUES ('66', 'STANAG 60', '0');
INSERT INTO items (id, name, amount) VALUES ('67', 'STANAG C-MAG', '0');
INSERT INTO items (id, name, amount) VALUES ('68', 'G36 AMMO', '0');
INSERT INTO items (id, name, amount) VALUES ('69', 'G36 C-MAG', '0');
--SMG AMMO
INSERT INTO items (id, name, amount) VALUES ('70', 'SMG-20', '0');
INSERT INTO items (id, name, amount) VALUES ('71', 'SMG-40', '0');
INSERT INTO items (id, name, amount) VALUES ('72', 'MP5 10MM MAG', '0');
INSERT INTO items (id, name, amount) VALUES ('73', 'CZ SCORPION EVO-3 AMMO', '0');
INSERT INTO items (id, name, amount) VALUES ('74', 'MP7 30', '0');
INSERT INTO items (id, name, amount) VALUES ('75', 'MP7 40', '0');
INSERT INTO items (id, name, amount) VALUES ('76', 'P90 50 ROUNDS', '0');
INSERT INTO items (id, name, amount) VALUES ('77', 'BIZON 64 AMMO', '0');
--SNIPER RIFLE AMMO
INSERT INTO items (id, name, amount) VALUES ('78', '.308 WINCHESTER', '0');
INSERT INTO items (id, name, amount) VALUES ('79', 'SVD AMMO', '0');
INSERT INTO items (id, name, amount) VALUES ('80', 'VSS-10', '0');
INSERT INTO items (id, name, amount) VALUES ('81', 'VSS-20', '0');
INSERT INTO items (id, name, amount) VALUES ('82', 'AWM .338 MAGNUM AMMO', '0');
INSERT INTO items (id, name, amount) VALUES ('83', '.50 BMG', '0');
--LIGHT MACHINE AMMO
INSERT INTO items (id, name, amount) VALUES ('84', 'M249 AMMO BOX', '0');
INSERT INTO items (id, name, amount) VALUES ('85', 'PKM AMMO BOX', '0');
-- ATACZMENTY
INSERT INTO items (id, name, amount) VALUES ('86', 'ACOG','0');
INSERT INTO items (id, name, amount) VALUES ('87', 'BLACKWATER LONG RANGE','0');
INSERT INTO items (id, name, amount) VALUES ('88', 'COMPACT SCOPE','0');
INSERT INTO items (id, name, amount) VALUES ('89', 'FLASH HIDER','0');
INSERT INTO items (id, name, amount) VALUES ('90', 'FORWARD GRIP','0');
INSERT INTO items (id, name, amount) VALUES ('91', 'HOLOGRAPHIC','0');
INSERT INTO items (id, name, amount) VALUES ('92', 'PSO-1','0');
INSERT INTO items (id, name, amount) VALUES ('93', 'PISTOL FLASHLIGHT','0');
INSERT INTO items (id, name, amount) VALUES ('94', 'PISTOL LASER','0');
INSERT INTO items (id, name, amount) VALUES ('95', 'RED DOT SP','0');
INSERT INTO items (id, name, amount) VALUES ('96', 'REFLEX SIGHT','0');
INSERT INTO items (id, name, amount) VALUES ('97', 'RIFLE FLASHLIGHT','0');
INSERT INTO items (id, name, amount) VALUES ('98', 'RIFLE LASER','0');
INSERT INTO items (id, name, amount) VALUES ('99', 'SMG GRIP','0');
INSERT INTO items (id, name, amount) VALUES ('100', 'SMG GRIP 2','0');
INSERT INTO items (id, name, amount) VALUES ('101', 'SILENCER','0');
INSERT INTO items (id, name, amount) VALUES ('102', 'SWISS ARMS SCOPE 8X','0');
INSERT INTO items (id, name, amount) VALUES ('103', 'TACTICAL SNIPER SCOPE','0');
INSERT INTO items (id, name, amount) VALUES ('104', 'RPK-74','0');
-- MISC
INSERT INTO items (id, name, amount) VALUES ('105', 'FRAG GRENADE','0');
INSERT INTO items (id, name, amount) VALUES ('106', 'COMPUND CROSSBOW','0');
(我无法真正发布错误输出图像,所以这里是一个链接:) http://i.imgur.com/OkN71uA.png
#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本对应的手册,以便在'--HANDGUN AMMO附近使用正确的语法 INSERT INTO项目(id,name,amount)VALUES('48','9MM MAG',第1行'0'
答案 0 :(得分:3)
撰写评论--
后必须加上空格。
在MySQL manual - 9.6 Comment Syntax
中查看更多内容 顺便说一下,你在其他方面遇到同样的问题:--HANDGUN AMMO
更改为-- HANDGUN AMMO
--SHOTGUN AMMO
更改为-- SHOTGUN AMMO
--ASSAULT RIFLE AMMO
更改为-- ASSAULT RIFLE AMMO
--SMG AMMO
更改为-- SMG AMMO
--SNIPER RIFLE AMMO
更改为-- SNIPER RIFLE AMMO
--LIGHT MACHINE AMMO
更改为-- LIGHT MACHINE AMMO
答案 1 :(得分:0)
答案 2 :(得分:0)
我注意到的一件事是你有很多代码不需要在那里。为什么不这样插入:
INSERT INTO items
(id, name, amount)
VALUES
('48', '9MM MAG', '0'),
('49', '.45 ACP STI EAGLE ELITE', '0'),
('50', '5.7 FN M240 MAG', '0'),
('51', 'DESERT EAGLE AMMO', '0'),
('52', '9X19 PARA MAG', '0');
至于它为何抛出错误,我不明白为什么会这样。你可能想要考虑的另一件事是为弹药创建一个单独的表,为武器创建另一个表,为misc项创建另一个表。然后,您需要创建一个主表,该表将使用可能的弹药列出武器。这样做会使您的架构更容易阅读和管理。