-2

嘿,我使用以下代码:

            bookseats = [0,1]
        print"What seats would you like to book?"
        bookseats[0] = raw_input("Choice : ")
        bookseats[1] = raw_input("What is their user ID? : ")
        cur.execute("SELECT * FROM seats WHERE Booked='N'")
        row = cur.fetchone()
        if row != None and row[2] == "S":
            booked = 'B'
            print "Seat Number:" , row[0] ,"Is now booked!"
            cur.execute("UPDATE seats SET CustID=? AND Booked=? WHERE Seat_name=? AND Day=?", (bookseats[1],booked,bookseats[0],choice)

但是当我这样做时,CustID 列也只是更改为 0,而 Booked 列没有切换到“B”表示预订,它只是停留在“N”上,请帮帮我!:(

4

1 回答 1

0

而不是这个查询:

UPDATE seats SET CustID=? AND Booked=? WHERE Seat_name=? AND Day=?

你应该使用这样的东西:

UPDATE seats SET CustID=?, Booked=? WHERE Seat_name=? AND Day=?

在这里查看有关UPDATE查询的更多信息:http: //www.w3schools.com/sql/sql_update.asp

于 2013-02-11T23:19:50.403 回答