我遇到了问题而我找不到错误。它不允许我更新我的索引并总是说SQL error or missing data type near WHERE syntax
。其他一切都有效。所以我认为你们可以看看这个:
Create Table: execute("CREATE TABLE Players (player TEXT, money DOUBLE, job TEXT, level INTEGER, exp DOUBLE)");
作品
Insert: DATABASE.execute("INSERT INTO Players VALUES ('" + player + "', " + money + ", '" + job.getJob() + "', " + job.getLevel() + ", " + job.getEXP() + ")");
作品
Update: DATABASE.execute("UPDATE Players WHERE player = '" + player.toLowerCase() + "' SET money = " + money + ", job = '" + job.getJob() + "', level = " + job.getLevel() + ", exp = " + job.getEXP());
无效
我使用以下值进行更新:
player = gemaken
money = 100.0
job.getJob() = miner
level = 0
exp = 0.0
提前致谢!
此致 Gemaken
答案 0 :(得分:2)
在SQL UPDATE
中,SET
部分首先出现,WHERE
部分出现在后面:
DATABASE.execute("UPDATE Players SET money = " + money + ", job = '" + job.getJob() + "', level = " + job.getLevel() + ", exp = " + job.getEXP()) + " WHERE player = '" + player.toLowerCase() + "';
另外,请考虑使用参数和预处理语句。
答案 1 :(得分:0)
请尝试这个
Update: DATABASE.execute("UPDATE Players SET money = " + money + ", job = '" + job.getJob() + "', level = " + job.getLevel() + ", exp = " + job.getEXP() WHERE player = '" + player.toLowerCase());
答案 2 :(得分:0)