Updating a record with a value from another table - MySQL (Python)

Viewed 71

I am trying to update a value in one table (csms) in MySQL from another table (serviceppl). I have attached the query I wrote and both tables, but the query does not work. It does not produce any error, but the record doesn't get updated. Help!

query = "select*from csms where feedback in('null', 'I expect a better one', 'Bad one! Need one again')"
mycursor.execute(query)
p = mycursor.fetchall()

for i in p:
    query_upserv = """update csms inner join serviceppl on csms.product = serviceppl.speciality
                      set serviceppl.name = csms.serviceman where csms.product = '{}'""".format(i[4])
    mycursor.execute(query_upserv)
    mycon.commit() 

See this for the table images.Please refer to this link or else you won't understand my query

1 Answers

If you want to update the column serviceman of the table csms then you must fix your SET clause:

set csms.serviceman = serviceppl.name 
Related