1

I'm trying to run the following statement:

INSERT INTO table (
    as,
    ad
    ,af,
    ag,
    ah,
    aj
)                                       
VALUES (
    'a',
    'b',
    'c',
    'd',
    'e',
    'f'
)
ON DUPLICATE KEY UPDATE (
    aj='dv',
    ah='ev',
    ag='fv'
);

and getting the following error:

You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the 
right syntax to use near '(ag='dv',ah='ev',ah='fv')' 
at line 3

Any advice?

thx

1
  • 2
    remove (), use only english='dv',indonesian='ev',japanese='fv' Commented Apr 20, 2012 at 10:42

1 Answer 1

5

Skip the ()..

 INSERT INTO site_domains_meta 
 (domainname,metatype,pagename,english,indonesian,japanese)
  VALUES ('a','b','c','d','e','f')
  ON DUPLICATE KEY UPDATE english='dv',indonesian='ev',japanese='fv';

http://dev.mysql.com/doc/refman/5.5/en/insert.html

Sign up to request clarification or add additional context in comments.

2 Comments

As an addition, you can use VALUES() instead of re-specifying data, i.e. ON DUPLICATE KEY UPDATE english = VALUES(english), indonesian = VALUES(indonesian), japanese = VALUES(japanese) as then it can update multiple-row inserts too with the correct values
perfect... thx... will tick once the time limit expires... cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.