21

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.

Thanks alot guys!

Juan Mellado
  • 14,973
  • 5
  • 47
  • 54
james
  • 919
  • 4
  • 11
  • 17

1 Answers1

36
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:

insert into products (name, price) values ('sprite', 9)
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223