2017-07-28 204 views
0

我想在我的數據庫使用兩個UPDATE查詢:sqlite3的錯誤:行值missused

UPDATE equipment 
SET equip_level = 'Hero' 
WHERE equip = ('Amulet of Immortality'); 

UPDATE equipment 
SET equip_level = 'Master' 
WHERE equip = ('Shield of Pitch Black', 'Blade of MageBane', 'Leggings of Spikes', 'Gloves of Quickling skin', 'Helm of the Fire King', 'Scythe of Death'); 

第一個工作得很好,但第二個(有多個條目)給了我以下錯誤:

[11:37:16] Error while executing SQL query on database 'test': row value misused 

,我正在看(https://digitalfellows.commons.gc.cuny.edu/2016/04/08/fun-times-with-sqlite-or-a-beginners-tutorial-to-data-management-and-databases-with-sql/)本教程使用以下格式第二個查詢:

UPDATE equipment 
SET equip_level = 'Master' 
WHERE equip = IN ('Shield of Pitch Black', 'Blade of MageBane', 'Leggings of Spikes', 'Gloves of Quickling skin', 'Helm of the Fire King', 'Scythe of Death') 

但是,這給了我一個語法錯誤:

[11:49:48] Error while executing SQL query on database 'test': near "IN": syntax error 

我如何糾正呢?

回答

1

去除等號:

UPDATE equipment 
SET equip_level = 'Master' 
WHERE equip IN ('Shield of Pitch Black', 'Blade of MageBane', 'Leggings of Spikes', 'Gloves of Quickling skin', 'Helm of the Fire King', 'Scythe of Death')