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

  • Home
  • SEARCH
  • 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 7014619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:32:43+00:00 2026-05-27T22:32:43+00:00

I have two tables that need the exact same values for denormalization purposes. Here’s

  • 0

I have two tables that need the exact same values for denormalization purposes.

Here’s the query.

first table

UPDATE Table_One 
SET win = win+1, streak = streak+1, score = score+200 
WHERE userid = 1 AND lid = 1 LIMIT 1

second table

UPDATE Table_Two 
SET win = win+1, streak = streak+1, score = score+200 
WHERE userid = 1 LIMIT 1

As you can see the only difference between both tables is their name and table two doesn’t have the field lid

Anyway to combine both updates to just one?

  • 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-27T22:32:43+00:00Added an answer on May 27, 2026 at 10:32 pm

    It should be possible with a multi-table update, as described in the documentation.

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

    UPDATE Table_One a INNER JOIN Table_Two b ON (a.userid = b.userid)
    SET
      a.win = a.win+1, a.streak = a.streak+1, a.score = a.score+200,
      b.win = b.win+1, b.streak = b.streak+1, b.score = b.score+200 
    WHERE a.userid = 1 AND a.lid = 1 AND b.userid = 1
    

    Note: Multi-table doesn’t support LIMIT, so this could cause more grief depending on the details.

    Stored procedures or transactions may be a nicer solution.

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

Sidebar

Related Questions

I have two tables that have the exact same structure. Table MasterList Acct_id(9) Name
I have a database two tables and a linking table that I need a
I have two tables that need to be related--a users table and an address_book
I have two tables that I am joining with the following query... select *
I have two tables that are related via a mapping table: keywords titles I
I have two tables which get updated at almost the exact same time -
I have two tables that need to be updated, Master and Identifiers: Master --MasterID
I have two tables that I need to join... I want to join table1
I have two tables that are connected via a join table in a many-to-many
I have a view that is joining two tables and ordering by the first

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.