Categories: MySQL

Copy one field to another in MySQL

Rule is simple:

udpate table_name set  destination_column=source_column

If you want to update multiple tables and you can join on that table you can use the join syntax also in the UPDATE:

UPDATE items,month SET items.price=month.price WHERE items.id=month.id;

OR

UPDATE TABLE_1 LEFT JOIN TABLE_2 ON TABLE_1.COLUMN_1= TABLE_2.COLUMN_2 SET TABLE_1.COLUMN = EXPR WHERE TABLE_2.COLUMN2 IS NULL

So to copy data from one field to another mysql mulitple rows.

UPDATE agreement a1 
       JOIN agreementtemp a2 
         ON a1.id = a2.id 
SET    a1._date2 = Concat(SUBSTRING(a2._date, 7), '-', SUBSTRING(a2._date, 4, 2) 
                   , '-', 
                                      SUBSTRING(a2._date, 1, 2));

Enjoy!

SGH

At the same time, I can’t think of anything more satisfying than sitting in front of TV, eating take-away, lights down low, in my pyjamas and watching crap on TV. Basically, I strive to live a balanced life. Fun. Serious. Fast. Slow. Brainy. Bimbotic. Intense. Lazy. You get the drift.

Recent Posts

Free GG Mug Mockup

GG Mug Mockup designed for logo branding of companies and brands.

6 years ago

Lovtony Font Duo – Modern Sans Serif

A great font/script for creating beautiful logos, posters, wedding invitations, blog posts, social media, and…

6 years ago

Free Men T-Shirt Mockup

Realistic T-Shirt Mockup PSD which you can use freely to showcase your apparel design.

6 years ago

Classic Coffee Mug Mock-up Free PSD

Classic coffee mug Mock-up Free PSD. Free mug mockup PSD to showcase your branding design…

6 years ago

Juliette – Stylish Handwritten Signature Font

Juliette - Stylish Handwritten Signature Font

6 years ago

XXII Aven Sans Serif Font Family

XXII Aven Font Family - a new modern all-caps sans serif font with versatility in creativity.

6 years ago