Append records from one table to another using the common field

There are many varied posts about this matter, but I am unable to find the answer I need. I am hoping this question is unique.

I am trying to append all the data from one table to another, without creating new records. The data in the second table is really a subset of data for a portion of the existing records in the first table.

For example: I have the table "SPK". And I want to write all of the data from SPK into the table "RCT". The common field between each record I want to match is the RegID, which is unique in both tables (i.e. there is only one SPK record per RCT record).

Answers


If I understand correctly, you mean append the columns in one table (call it SECOND) to the other (call it FIRST).

In that case, does this work ?

UPDATE 
    regcontactsTest
    JOIN 
    speakersTest 
    ON speakersTest.RegistrationID = regcontactsTest.RegistrationID
SET regcontactsTest.presentationtitle = speakersTest.presentationtitle

EDIT: Updated the query based on Mariadb syntax


You need to use JOIN. For general Update join :

 update tab1 a 
   join tab2 b ON a.join_colA = b.join_colB  
   SET a.columnToUpdate = [something]

Or in other words:

update
  tab1 a 
  join tab2 b on ..
set a.field=...;

Need Your Help

Parsing tcl arrays in ruby with treetop

ruby parsing grammar treetop

I have a bunch of data in (what i think is) a tcl array. Basically it's in the form of {a {b c} d {e f} g}. It's only nested one deep, but isn't always nested, that is to say, a may just be a or it...

C#/.NET Lexer Generators

c# .net parsing generator lexical-analysis

I'm looking for a decent lexical scanner generator for C#/.NET -- something that supports Unicode character categories, and generates somewhat readable & efficient code. Anyone know of one?