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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:10:59+00:00 2026-05-29T09:10:59+00:00

Hi I have a mysql table having the following fields A INT, B INT,

  • 0

Hi I have a mysql table having the following fields

                    A INT, B INT, C INT, D INT, Count INT 

I want the insertion to be unique for the values of ‘A’, ‘B’, ‘C’ ANT ‘D’. ie if there is a ‘Count’ entry for a particular values of ‘A’, ‘B’, ‘C’ AND ‘D’ then there will be only UPDATION of ‘Count’ field for the same values of ‘A’, ‘B’, ‘C’ AND ‘D’. The problem is that more than 1 users are trying to Insert same value to database simultaneously, so there is a chance of multiple entry of same values to database.I am using php to check whether an entry is present for a particular values of ‘A’, ‘B’, ‘C’ AND ‘D’, if yes I can make an update. But for the first time without an entry there is a chance that 2 or more user’s can make an insert of same values for A’, ‘B’, ‘C’ AND ‘D’ at the same time, like

                           A=10, B=8, C=4, D=5 AND Count=1

                           A=10, B=8, C=4, D=5 AND Count=2

but I want an Insertion of “A=10, B=8, C=4, D=5 AND Count=1” for first(second) user and the row get updated to “A=10, B=8, C=4, D=5 AND Count=3” for second(first) user even if both user’s tried to insert values at the same time. How can I fix this problem ?

  • 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-29T09:11:00+00:00Added an answer on May 29, 2026 at 9:11 am

    1) Don’t use ‘count’ as a column name – it is a MySQL keyword

    2) You need to make a UNIQUE key on the columns that you want to watch for duplicates of and then use the ‘on duplicate key update’ funcitonality: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

    insert into mytable
    (a, b, c, d, entryCount )
    values
    ( ?, ?, ?, ?, 0)
    on duplicate key update
    a = ?, b = ?, c = ?, d = ?, entryCount = entryCount + 1;

    That code is ‘thread safe’ at a MySQL level, so you don’t need to handle it in PHP at all.

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

Sidebar

Related Questions

I have a MySql table having the following structure: ontology_term pathway_id pathway_name I want
So im having a problem (obviously). I have the following MySQL table data 7
I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION
I have a MySQL table consisting of: CREATE TABLE `url_list` ( `id` int(10) unsigned
I have a MySQL table holding lots of records that i want to give
I'm having the following problem with 2 MySQL tables that have a relation: I
I have following mysql table: Item Name Listing Fee Listing Type watch $0.20 LISTED
I have user table having fields gender and first name like this.. The value
I have a database table named 'favoritecats' with the following fields: id catName catId
I am using MySQL and I am having the following scenario: Table nodes: node_id,

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.