Nadia Krawczyk Nadia Krawczyk - 3 months ago 11
MySQL Question

sql newbie gets sql error, dont know why

This is my sql query:

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');


(I can't really post error output image so here's a link:)
http://i.imgur.com/OkN71uA.png

#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 '--HANDGUN AMMO
INSERT INTO items (id, name, amount) VALUES ('48', '9MM MAG', '0' at line 1

Answer

to write the comment -- must be followed by a white space.

see more in the MySQL manual - 9.6 Comment Syntax

BTW, you have the same problem in other lines:

  • --HANDGUN AMMO change to -- HANDGUN AMMO
  • --SHOTGUN AMMO change to -- SHOTGUN AMMO
  • --ASSAULT RIFLE AMMO change to -- ASSAULT RIFLE AMMO
  • --SMG AMMO change to -- SMG AMMO
  • --SNIPER RIFLE AMMO change to -- SNIPER RIFLE AMMO
  • --LIGHT MACHINE AMMO change to -- LIGHT MACHINE AMMO
Comments