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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:02:09+00:00 2026-05-31T23:02:09+00:00

I am trying to update rows in a data table that intersect rows in

  • 0

I am trying to update rows in a data table that intersect rows in a smaller index table. The two tables are joined on the composite PK of the data table, and explain-select using the same criteria shows that the index is being used properly, and the correct unique rows are fetched – but I’m still having issues with the update.

The update on the joined tables works fine when there’s only 1 row in the temp table, but when I have more rows, I get MySql Error 1175, and none of the WHERE conditions I specify are recognized.

I’m aware that I can just switch off safe mode with SET SQL_SAFE_UPDATES=0, but can anyone tell me what I’m not understanding here? Why is my WHERE condition not accepted, and why does it even need a where when I’m doing a NATURAL JOIN – and why does this work with only one row in the right-hand-side table (MyTempTable)?

The Code

Below is vastly simplified, but structurally identical create table & updates representing my problem.

-- The Data Table.
Create Table MyDataTable
(
    KeyPartOne int not null,
    KeyPartTwo varchar(64) not null,
    KeyPartThree int not null,
    RelevantData varchar(200) null,
    Primary key (KeyPartOne, KeyPartTwo, KeyPartThree)
) Engine=InnoDB;

-- The 'Temp' table.
Create Table MyTempTable
(
    KeyPartOne int not null,
    KeyPartTwo varchar(64) not null,
    KeyPartThree int not null,
    Primary key (KeyPartOne, KeyPartTwo, KeyPartThree)
)Engine=Memory;

-- The Update Query (works fine with only 1 row in Temp table)
update MyDataTable natural join MyTempTable 
set RelevantData = 'Something Meaningful';

-- Specifying 'where' - roduces same effect as the other update query
update MyDataTable mdt join MyTempTable mtt
on mdt.KeyPartOne = mtt.KeyPartOne
and mdt.KeyPartTwo = mtt.KeyPartTwo
and mdt.KeyPartThree = mtt.KeyPartThree
set RelevantData = 'Something Meaningful'
where mdt.KeyPartOne = mtt.KeyPartOne
and mdt.KeyPartTwo = mtt.KeyPartTwo
and mdt.KeyPartThree = mtt.KeyPartThree;

P.S. Both of the above update statements work as expected when the temp table contains only one row, but give me the error when there’s more than one row. I’m seriously curious about why!

  • 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-31T23:02:11+00:00Added an answer on May 31, 2026 at 11:02 pm

    Per the MySql forum, the update queries are valid, and the fact that they don’t work in Workbench with safe-update mode turned on does not indicate that there’s anything wrong with the index. It’s just a quirk of Workbench’s “don’t-shoot-yourself-in-the-foot” mode. 🙂

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

Sidebar

Related Questions

I am trying to update a field in a table with data from another
I am trying to use PHP and MySQL's Create Table Select between two different
I have the following SQL statement where i'm trying to update multiple rows matching
I am trying to update a column in my table which was last inserted.
So I have a table of data that is 10,000 lines long. Several of
I'm trying to write a Java app that imports a data file. The process
I'm trying to pass a data table to a stored procedure. The table has
I'm trying to append rows upon scrolling of a table using a modified version
I'm trying to get a query to compare two tables by LEFT OUTER JOINing
I have 2 tables that I'm trying to use to perform some calculations. My

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.