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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:34:45+00:00 2026-05-25T09:34:45+00:00

Problem: I’d like to update rows that don’t match a left join (or another

  • 0

Problem: I’d like to update rows that don’t match a left join (or another fast solution).
Initial goal: Update records of mytable1 that have state=0 and has either (XOR!) column “a” that matches mytable2, or column “b” that matches mytable2 (“a” and “b” should not both match!). Set the records of both tables to state=5.

I tried (and failed):

update mytable1 as t1 
    left join mytable2 as t2 on (t1.a=t2.a and t1.b=t2.b) 
set t1.state=5,t2.state=5 
where t1.state=0 and t2.state=0 and t2.a is null;

As you can see I tried to join all records that match BOTH values, so that I could update records that don’t match, also updating the rows that didn’t match in mytable2. Rows from mytable1 get updated but not those from table2. I could update the rows that DO match the left join, but that’s 99% of the rows which would be a performance hit I think (I did ask this question so I never got to compare ;).

Thank you for your time.

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

    Here’s what I came up with:

    update mytable1 t1 inner join mytable2 t2 on (t1.a=t2.a or t1.b=t2.b or t2.c=t1.c) set t1.state=5,t2.state=5 where((cast(t1.a=t2.a as unsigned integer) + (cast(t1.b=t2.b as unsigned integer) + (cast(t1.c=t2.c as unsigned integer)) <3) and t1.state=0;
    

    Yes, max 2 values could be equal, only 1 should be different.

    It looks like it works, and it’s fast. Any comment?

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

Sidebar

Related Questions

Problem: Ajax suggest-search on [ n ] ingredients in recipes. That is: match recipes
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Problem Language: C# 2.0 or later I would like to register context handlers to
Problem: We have a web app that calls some web services asynchronously (from the
Problem Statement - Would like to know if particular web app user is active
Problem: I have a large Visual C++ project that I'm trying to migrate to
Problem: I need somehow to checkout an existing branch of a project that is
Problem: I don't know why my script is not loading a value into the
Problem: Trying to create a Mix that is applied to the AVPlayerItem, but it

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.