Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6623579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:32:57+00:00 2026-05-25T21:32:57+00:00

I’m trying to insert on duplicate key update in Mysql using below: INSERT INTO

  • 0

I’m trying to insert on duplicate key update in Mysql using below:

INSERT INTO `generic_client_data` (id, keyword, client_id, desc_id) 
VALUES (NULL, qqqq, 115, 0) ON DUPLICATE KEY 
UPDATE keyword=VALUES(qqqq), client_id=VALUES(115), desc_id=VALUES(0)

but it gives me this error:

#1064 - 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 '115), desc_id=VALUES(0)' at line 1

Is there a reason why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:32:58+00:00Added an answer on May 25, 2026 at 9:32 pm

    The VALUES “function” in the UPDATE part of the query refers to the column names that you used in the INSERT part. What you want is this:

    INSERT INTO `generic_client_data` (id, keyword, client_id, desc_id) 
    VALUES (NULL, 'qqqq', 115, 0) ON DUPLICATE KEY 
    UPDATE keyword=VALUES(keyword), client_id=VALUES(client_id), desc_id=VALUES(desc_id);
    

    This way, you can refer back to whatever values you wanted to insert; they may be calculated values, or they may have come from a SELECT query. When you get into more complex queries, I think you’ll find this much more convenient than what you were trying to do.

    Most of the time, when you use ON DUPLICATE KEY UPDATE, you will have no reason to do anything other than

    UPDATE x=VALUES(x), y=VALUES(y), z=VALUES(z)
    

    for whatever columns you wanted to insert.

    If you really just wanted to insert the values that you had specified for the various columns, then leave out the VALUES(); you could just do it like this:

    INSERT INTO `generic_client_data` (id, keyword, client_id, desc_id) 
    VALUES (NULL, 'qqqq', 115, 0) ON DUPLICATE KEY 
    UPDATE keyword='qqqq', client_id=115, desc_id=0
    

    However, this requires you to enter all the values twice, and every time you change the statement you’ll have to make sure everything matches up.

    It wouldn’t hurt to read the manual, as the error message suggests:
    http://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.