我想运行一个命令来将项目添加到项目表中。我使用MySQL来运行查询并将MySQL用于数据库。
这是结构:
+------------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| Name | varchar(25) | YES | | NULL | |
| TypeID | int(11) | YES | MUL | NULL | |
| RarityID | int(11) | YES | MUL | NULL | |
| IconImageID | int(11) | YES | MUL | NULL | |
| SpriteMapID | int(11) | YES | MUL | NULL | |
| Resistance | int(3) | YES | | NULL | |
| Attack | int(3) | YES | | NULL | |
| Speediness | int(3) | YES | | NULL | |
| GoldFinder | int(3) | YES | | NULL | |
| TresureHunting | int(3) | YES | | NULL | |
| CreatureResearch | int(3) | YES | | NULL | |
| AttackDuration | int(3) | YES | | NULL | |
| RemedyMastery | int(3) | YES | | NULL | |
| AttackAccuracy | int(3) | YES | | NULL | |
| AttackMastery | int(3) | YES | | NULL | |
| CriticalStrike | int(3) | YES | | NULL | |
| Sell | int(5) | YES | | NULL | |
| Buy | int(5) | YES | | NULL | |
| LevelID | int(11) | YES | MUL | NULL | |
+------------------+-------------+------+-----+---------+----------------+
查询:
INSERT INTO `Items` (Name,TypeID,RarityID,IconImageID,SpriteMapID,Resistance,Attack,Speediness,GoldFinder,TresureHunting,CreatureResearch,AttackDuration,RemedyMasteryAttackAccuracy,AttackMastery,CriticalStrike,Sell,Buy,LevelID)VALUES(
('Small Red Tonic', 1, 1, 22, NULL, 25,0,0,0,0,0,0,0,0,0,0,0,0, 50, 20, 1),
('Medium Red Tonic', 1, 2, 23, NULL, 100,0,0,0,0,0,0,0,0,0,0,0,0, 150, 60, 15),
('Large Red Tonic', 1, 3, 24, NULL, 400,0,0,0,0,0,0,0,0,0,0,0,0, 500, 200, 30),
('Small Blue Tonic', 1, 1, 25, NULL, 0,25,0,0,0,0,0,0,0,0,0,0,0, 50, 20, 1),
('Medium Blue Tonic', 1, 2, 26, NULL, 0,100,0,0,0,0,0,0,0,0,0,0,0, 150, 60, 15),
('Large Blue Tonic', 1, 3, 27, NULL, 0,400,0,0,0,0,0,0,0,0,0,0,0, 500, 200, 30),
('Small Purple Tonic', 1, 1, 28, NULL, 25,25,0,0,0,0,0,0,0,0,0,0,0, 75, 30, 1),
('Medium Purple Tonic', 1, 2, 29, NULL, 100,100,0,0,0,0,0,0,0,0,0,0,0, 250, 90, 15),
('Large Purple Tonic', 1, 3, 30, NULL, 400,400,0,0,0,0,0,0,0,0,0,0,0, 800, 250, 30),
('Turnip', 2, 1, 31, NULL, 10,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Potato', 2, 2, 32, NULL, 25,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Apple', 2, 2, 33, NULL, 25,25,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 10),
('Watermelon', 2, 3, 34, NULL, 50,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Cheese', 2, 3, 35, NULL, 50,50,0,0,0,0,0,0,0,0,0,0,0, 50, NULL, 10),
('Training Jacket', 3, 1, 36, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Bandanna', 4, 1, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Trowsers', 5, 1, 40, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Trainers', 6, 1, 42, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Staff', 7, 1, 44, 45,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Basic Farmer''s Jursy', 3, 1, 46, 47, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Jursy', 4, 1, 48, 49, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Trowsers', 5, 1, 50, 51 , 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Trainers', 6, 1, 52, 53, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Staff', 7, 1, 54, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 60, 20, 2),
('Elegant Chef''s Top', 3, 1, 56, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Hat', 4, 1, 58, 59, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Trowsers', 5, 1, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 75, 25, 3),
('Elegant Chef''s Shoes', 6, 1, 62, 63 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Staff', 7, 1, 64, 65 , 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 75, 25, 3),
('Traditional Hunter''s Top', 3, 1, 66, 67 , 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Hat', 4, 1, 68, 69, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Trowsers', 5, 1, 70, 71, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Shoes', 6, 1, 72, 73 , 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Staff', 7, 1, 74, 75 , 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 45, 4),
('Critical Coaches Top', 3, 1, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 250, 80, 5),
('Critical Coaches Hat', 4, 1, 78, 79 , 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 250, 80, 5),
('Critical Coaches Trowsers', 5, 1, 80, 81, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 250, 80, 5),
('Critical Coaches Shoes', 6, 1, 82, 83 , 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 250, 80, 5),
('Critical Coaches Staff', 7, 1, 84, 85 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 250, 80, 5));
当我运行Insert命令时,它会出现以下错误:
ERROR 1241 (21000): Operand should contain 1 column(s)
错误是什么?我哪里错了?
答案 0 :(得分:1)
假设其他一切都是正确的:
To eliminate the Operand should contain 1 column(s). error.
只需删除值周围的外部()。
但是还有其他错误,你只有18列和21列。
INSERT INTO `Items` (Name,TypeID,RarityID,IconImageID,SpriteMapID,Resistance,Attack,Speediness,GoldFinder,TresureHunting,CreatureResearch,AttackDuration,RemedyMasteryAttackAccuracy,AttackMastery,CriticalStrike,Sell,Buy,LevelID)
VALUES
('Small Red Tonic', 1, 1, 22, NULL, 25,0,0,0,0,0,0,0,0,0,0,0,0, 50, 20, 1),
('Medium Red Tonic', 1, 2, 23, NULL, 100,0,0,0,0,0,0,0,0,0,0,0,0, 150, 60, 15),
('Large Red Tonic', 1, 3, 24, NULL, 400,0,0,0,0,0,0,0,0,0,0,0,0, 500, 200, 30),
('Small Blue Tonic', 1, 1, 25, NULL, 0,25,0,0,0,0,0,0,0,0,0,0,0, 50, 20, 1),
('Medium Blue Tonic', 1, 2, 26, NULL, 0,100,0,0,0,0,0,0,0,0,0,0,0, 150, 60, 15),
('Large Blue Tonic', 1, 3, 27, NULL, 0,400,0,0,0,0,0,0,0,0,0,0,0, 500, 200, 30),
('Small Purple Tonic', 1, 1, 28, NULL, 25,25,0,0,0,0,0,0,0,0,0,0,0, 75, 30, 1),
('Medium Purple Tonic', 1, 2, 29, NULL, 100,100,0,0,0,0,0,0,0,0,0,0,0, 250, 90, 15),
('Large Purple Tonic', 1, 3, 30, NULL, 400,400,0,0,0,0,0,0,0,0,0,0,0, 800, 250, 30),
('Turnip', 2, 1, 31, NULL, 10,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Potato', 2, 2, 32, NULL, 25,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Apple', 2, 2, 33, NULL, 25,25,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 10),
('Watermelon', 2, 3, 34, NULL, 50,0,0,0,0,0,0,0,0,0,0,0,0, NULL, 20, 1),
('Cheese', 2, 3, 35, NULL, 50,50,0,0,0,0,0,0,0,0,0,0,0, 50, NULL, 10),
('Training Jacket', 3, 1, 36, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Bandanna', 4, 1, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Trowsers', 5, 1, 40, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Trainers', 6, 1, 42, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Training Staff', 7, 1, 44, 45,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 20, 1),
('Basic Farmer''s Jursy', 3, 1, 46, 47, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Jursy', 4, 1, 48, 49, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Trowsers', 5, 1, 50, 51 , 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Trainers', 6, 1, 52, 53, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 60, 20, 2),
('Basic Farmer''s Staff', 7, 1, 54, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 60, 20, 2),
('Elegant Chef''s Top', 3, 1, 56, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Hat', 4, 1, 58, 59, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Trowsers', 5, 1, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 75, 25, 3),
('Elegant Chef''s Shoes', 6, 1, 62, 63 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 75, 25, 3),
('Elegant Chef''s Staff', 7, 1, 64, 65 , 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 75, 25, 3),
('Traditional Hunter''s Top', 3, 1, 66, 67 , 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Hat', 4, 1, 68, 69, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Trowsers', 5, 1, 70, 71, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Shoes', 6, 1, 72, 73 , 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 125, 40, 4),
('Traditional Hunter''s Staff', 7, 1, 74, 75 , 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 45, 4),
('Critical Coaches Top', 3, 1, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 250, 80, 5),
('Critical Coaches Hat', 4, 1, 78, 79 , 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 250, 80, 5),
('Critical Coaches Trowsers', 5, 1, 80, 81, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 250, 80, 5),
('Critical Coaches Shoes', 6, 1, 82, 83 , 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 250, 80, 5),
('Critical Coaches Staff', 7, 1, 84, 85 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 250, 80, 5);
答案 1 :(得分:0)
我刚刚解雇了这个查询,它完美地工作了很好......!
INSERT INTO `Items` (`ID`, `Name`, `TypeID`, `RarityID`, `IconImageID`,`SpriteMapID`, `Resistance`, `Attack`, `Speediness`, `GoldFinder`, `TresureHunting`, `CreatureResearch`, `AttackDuration`, `RemedyMastery`, `AttackAccuracy`, `AttackMastery`, `CriticalStrike`, `Sell`, `Buy`, `LevelID`) VALUES (NULL, 'Small Red Tonic', '1', '1', '22', NULL, '25', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '50', '20', '1'), (NULL, 'Medium Red Tonic', '1', '2', '23', NULL, '100', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '150', '60', '15');
您可以通过附加查看上述语法并在上面的代码中执行所需的更改来添加更多值。!
我在查询中发现的第一个非常基本的错误是两个列名之间没有逗号:
,RemedyMasteryAttackAccuracy,
shoukd be
,RemedyMastery,AttackAccuracy,
第一线...... !!
并尝试执行此操作。我希望它有所帮助。!