SQL 更改 SQLite3 中的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4686376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing a value in SQLite3
提问by james
I'll start off by showing the code:
我将首先展示代码:
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)
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.
将可乐行的价格列的值更改为 12 的 SQLite3 代码是什么。
所以我希望输出是可乐 12 sprite 9。
Thanks alot guys!
非常感谢各位!
回答by mechanical_meat
UPDATE products
SET price = 12
WHERE name = 'coke' AND price = 8;
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:
这些可能只是转录错误或拼写错误,但您应该table
从INSERT
语句中删除该词,并且列名不需要单引号,因此语句应如下所示:
insert into products (name, price) values ('sprite', 9)