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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:27:43+00:00 2026-06-01T22:27:43+00:00

I have 2 instances of a program, accessing 1 table in a database. Table

  • 0

I have 2 instances of a program, accessing 1 table in a database.
Table points

game    |  player1  |  player2
--------|-----------|-----------
Poker   |    5      |   
Skat    |    8      |    4
Bridge  |           |   10

If player1, using the first instance, wants to save his points (e.g. Poker) into the table, it has to be made sure, whether Poker is already there. If not, Poker will be inserted together with the points of player1. But if Poker was already inserted by player2, only the points of player1 should be inserted (the row should only be altered).

How can I make sure, that every sort of game is only inserted once and in this case only the points are inserted (altered)?
I think, the column game has to be unique.

My solution is to query the sort of game at first and check the number of rows. If there are 0 rows, insert the game and points, if there is already 1 row, only insert the points.
But is there a better/faster solution, whithout querying at first?

  • 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-01T22:27:45+00:00Added an answer on June 1, 2026 at 10:27 pm
    INSERT INTO points (game,player1) VALUES ('Poker',5)
        ON DUPLICATE KEY UPDATE player1=5;
    

    For more information, see the MySQL documentation: INSERT … ON DUPLICATE KEY Syntax.

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

Sidebar

Related Questions

Greetings I have a program that creates multiples instances of a class, runs the
I have two programs which are accessing a directory using the .NET Directory class
In my program I have multiple instances of a specific class Tracer (A1,B2,C3 etc).
In my program I have a Class Tracer: using System; using System.Collections.Generic; using System.Linq;
I have multiple instances of a program and each has its own install directory
I have a program that will store many instances of one class, let's say
I have a situation where I might have multiple instances of a program running
I have 2 programs, both written in Java. The first launches several instances of
In my program I have two JFrame instances. When I click next button I
I have a program that only allows one instance of itself to run. I

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.