-3

As you can see from the image I have a table called wpw8_postmeta where it has four columns and I have searched for the term release and got the following results.

I want to copy the results (release_date [meta_value]) to another table called wpw8_test using the post_id as foreign key/primary key.

enter image description here

The second table looks like this

enter image description here

After the update will be done it should look like this

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Shagor
  • 1
  • 5
  • what column types are meta_value and relase_date? – Turo Jul 14 '20 at 10:23
  • 1
    Please [use text, not images/links, for text--including tables & ERDs](https://meta.stackoverflow.com/q/285551/3404097). Use images only for what cannot be expressed as text or to augment text. Please in code questions give a [mre]--cut & paste & runnable code, including smallest representative example input as code; desired & actual output (including verbatim error messages); tags & versions; clear specification & explanation. For SQL that includes DBMS & DDL (including constraints & indexes) & input as code formatted as a table. [ask] Show what you can do, don't ask us to write your code. – philipxy Jul 14 '20 at 10:29
  • Does this answer your question? [Update one MySQL table with values from another](https://stackoverflow.com/questions/5727827/update-one-mysql-table-with-values-from-another) – MrUpsidown Jul 14 '20 at 11:15

1 Answers1

-1

You seem to be looking for the update ... join syntax:

update wpw8_test t
inner join wpw8_postmeta p on p.post_id = t.post_id
set t.release_date = p.meta_value
where p.meta_key like '%release%'
GMB
  • 216,147
  • 25
  • 84
  • 135