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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:23:21+00:00 2026-06-10T08:23:21+00:00

I have a table 1 in wordpress as wp_term_relationships ( object_id bigint(20), term_taxonomy_id bigint(20),

  • 0

I have a table 1 in wordpress as

wp_term_relationships (
   object_id bigint(20),
   term_taxonomy_id bigint(20),
   term_order int(11)
)

and table 2 as

 wp_test (
    object_id bigint(20),
    term_taxonomy_id bigint(20)
)

Now I am trying to update wp_term_relationships with the values in wp_test as

update ignore wp_term_relationships m1 
inner join wp_test m2
on (m1.term_taxonomy_id = m2.term_taxonomy_id)
set m1.object_id = m2.object_id

However, all the values of wp_test do not get updated to wp_term_relationships

I have even tried straight up inserting the values from wp_test into wp_test_relationships

by using an insert as

insert ignore into wp_term_relationships(object_id, term_taxonomy_id)
select object_id, term_taxonomy_id from wp_test

But it just updates the term_taxonomy_id values with the corresponding object_id values as 0 or
object_id values with the corresponding term_taxonomy_id values as 0

How can I transfer these 2 columns from wp_test into wp_term_relationships

  • 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-10T08:23:23+00:00Added an answer on June 10, 2026 at 8:23 am

    I think what you need is an INSERT without IGNORE and with ON DUPLICATE KEY UPDATE instead:

    INSERT INTO 
      wp_term_relationships (object_id, term_taxonomy_id)
    SELECT 
      object_id, 
      term_taxonomy_id 
      FROM wp_test
    ON DUPLICATE KEY UPDATE 
      wp_term_relationships.term_taxonomy_id = VALUES(term_taxonomy_id)
    

    Note that this assumes that you have a unique constraint on wp_term_relationships.object_id

    edit for different case:

    If you mean that what constitutes a "duplicate" is a distinct combination of the two columns, then you need to add a unique constraint on the two columns in MySQL, and then use your INSERT IGNORE query:

    ALTER TABLE wp_term_relationships ADD UNIQUE (object_id, term_taxonomy_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom database table for a plugin I wrote for wordpress. Now
I have a table like this (using wordpress) +---------+----------+------------+ | meta_id | meta_key |
I have a wordpress loop that pulls all of my data from a table...
I am trying to pull data from a table I have imported into my
I have a Wordpress site which has post ratings stored in the wp_ratings table,
I have a custom table in my WordPress database named post_votes used for voting
I'm trying to run a UPDATE using REPLACE on my MySQL database. I have
If i add a column to the wp_posts table in wordpress may i have
I have WordPress instances with each in its own database. For an update I
I'm trying to update tables in my wordpress mu database. I want to update

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.