更改 SQLite3 中的值 [英] Changing a value in SQLite3
本文介绍了更改 SQLite3 中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将首先展示代码:
create table products ('name' text primary key, 'price' INTEGER)
insert into table products ('name', 'price') values ('coke', 8)
insert into table products ('name', 'price') values ('sprite', 9)
将可乐行的价格列的值更改为 12 的 SQLite3 代码是什么.
所以我希望输出是coke 12 sprite 9.
What would be the SQLite3 code to change the value of the price column for the coke row to 12.
So I want the output to be coke 12 sprite 9.
非常感谢大家!
推荐答案
UPDATE products
SET price = 12
WHERE name = 'coke' AND price = 8;
这些可能只是转录错误或拼写错误,但您应该从您的 INSERT
语句中删除单词 table
,并且您不需要在列名周围加上单引号,因此语句应如下所示:
These might just be transcription errors or typos, but you should remove the word table
from your INSERT
statements, and you don't need single-quotes around column names, so the statement should look like:
insert into products (name, price) values ('sprite', 9)
这篇关于更改 SQLite3 中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文