CharlieC
CharlieC

Reputation: 123

What is the MySql Update equivalent of this?

What is the MySql UPDATE equivalent of this ?

INSERT INTO items (title, url) VALUES (%s, %s)", (listtitle[0], listlink[0])) 

Upvotes: 0

Views: 157

Answers (2)

Gruby
Gruby

Reputation: 21

Try this:

"UPDATE items SET title = %s, url= %s" % listtitle[0], listlink[0]

Upvotes: 0

Christoph Werner
Christoph Werner

Reputation: 141

"update items
    set title = '{0}',
        url = '{1}'
  where COLUMN = VALUE
    and COLUMN2 = VALUE2".format(listtitle[0], listlink[0])

Replace the words in uppercase with the specific values or otherwise you would update the whole table.

Unknown column in 'field list' error on MySQL Update query


Try this

self.cursor.execute("UPDATE items SET descs ='{0}'".format(item['title'][0]))

instead of this

self.cursor.execute('UPDATE items SET descs =%s' % item['title'][0])

Upvotes: 1

Related Questions