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 8565413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:25:17+00:00 2026-06-11T17:25:17+00:00

I am using a API to fetch records from a different server and insert

  • 0

I am using a API to fetch records from a different server and insert into my local database but when a particular field say apiserverID is duplicate i just want to update fields.
my problem is that i have table structure as

  • myPrimaryKey
  • apiserverID
  • ….
  • …..
  • …..
  • updateDate

now i want simple procedure to update the row if apiserverID is duplicate.
Only solution i know is i have to check (SELECT) if the key apiserverID exist then update else insert.
but i don’t want do programming for this is this possible in one query

EDIT : Main problem is that INSERT … ON DUPLICATE KEY UPDATE don’t work for a particular field, it include all the keys to check duplicity

  • 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-06-11T17:25:18+00:00Added an answer on June 11, 2026 at 5:25 pm

    if there is a single multiple-column unique index on the table, then the update uses (seems to use) all columns (of the unique index) in the update query.

    So if there is a UNIQUE(a,b) constraint on the table in the example, then the INSERT is equivalent to this UPDATE statement:

    UPDATE table SET c=c+1 WHERE a=1 AND b=2;

    (and not “a=1 OR b=2”)

    But in your case it will work as expected because first one is your primary key and it will never be duplicate form the server so only thing which can be duplicate is your apiserverID so when ever found duplicate it will update the row else always a new insert will be executed

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

Sidebar

Related Questions

i m using Youtube gdata api to fetch data from youtube. but i m
I am using graph API. I have to fetch feed(i.e.. posts on the particular
I'm using an API from a different site that returns a couple of 'pricepoint
I was using Google Weather API to fetch weather info, but apparently Google had
I'm using the facebook api to fetch the user's facebook id and then insert
I want to fetch the Facebook user's online friends using Graph API but I
I am using the JavaMail API to fetch mails. Earlier today I succeeded in
I'm using Facebook Connect along with the Facebook Graph API to fetch user's email
I want to update Paypal Order status and add tracking number using API. but
i am using Last.fm API to fetch some info of artists .I save info

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.