0

I'm trying to make a conditional statement in SQLite that would update a column value if it's 'None', but if that column already has a value, then do an insert with the whole new entry. This can be done in one command or it has to be in 2 commands?

Column : TV = 'None' The script would update TV for the first time with TV = 'Sony' If a new brand is available, the SQL command would check if TV = 'None' and if it's not, insert another entry with TV = 'Samsung'

EDIT: Could be table "Sells" with 3 columns: TV, Store, Type

UPDATE Sells SET TV='Sony' WHERE Store='Chicago' AND Type ='4k'

n00bz0r
  • 87
  • 9
  • 1
    I guess TV is the name of a column of your table. Is there only 1 row in that table or only 1 row with the value 'None'? Post sample data and expected results to clarify what you want. – forpas Jul 05 '21 at 17:46
  • Does this answer your question? [SQLite - UPSERT \*not\* INSERT or REPLACE](https://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace) – Michael Ruth Jul 05 '21 at 18:03
  • I added an example for what i'm trying to do. – n00bz0r Jul 05 '21 at 19:10

0 Answers0