Markus
Markus

Reputation: 3782

INSERT ... ON DUPLICATE KEY UPDATE does not work in my DB

I created a table entries with UNIQUE KEY title. Now I want to execute the query INSERT ... ON DUPLICATE KEY UPDATE, but I get compilation errors in phpMyAdmin:

Query:

INSERT INTO `entriess` (`title`, `description`)
    VALUES ("TEST", "TEST")
    ON DUPLICATE KEY UPDATE `title`=`AAA`

enter image description here

What am I doing wrong?

enter image description here

Upvotes: 0

Views: 799

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 76464

You have a syntax error. Change the query to

INSERT INTO `entriess` (`title`, `description`)
    VALUES ('TEST', 'TEST')
    ON DUPLICATE KEY UPDATE `title`='AAA'

In MySQL we enclose varchars into apostrophes, not into quotes.

Upvotes: 2

Related Questions