我想从表中插入一行到新表中,但是在我这样做时更改一个值。是否有可能在一个声明中这样做?
目前我有:
db = sqlite3.connect('C:/Desktop')
db.execute("""insert into table2 select * from table1 where
ID = {0}""".format(5))
db.execute("""update table2 set column = {0} where ID = {1}""".format("new string",5)
db.commit()
db.close()
答案 0 :(得分:3)
将!
替换为实际列列表,然后将该列替换为新值:
*
答案 1 :(得分:0)
是的,您可以使用
INSERT OR REPLACE INTO table(column_list)
VALUES(value_list);