2

我想更新包含多行的sqlite上的表

tablenew  
id  status
a   old
b   ask
c   old
d   old

ETC...

list = ['a', 'b', 'c']

cur.execute("update tablenew set status =? where id = ?", ('new',list))

如何在python中做到这一点?

4

1 回答 1

4

使用IN运算符:

cur.execute("update tablenew set status = ? where id IN ?", ('new', list))
于 2012-05-11T06:14:42.550 回答