Moving data from one column to another similar column in another MYSQL table

I am currently working on a web system using Mysql db.

I realized that I initially incorrectly configured the columns in the tables and

Now I need to move the data from one column of the table (receiptno) to the table (clients) to the same column of the table (receiptno) in the table (income).

I am still inexperienced with Mysql, and therefore I do not know the mysql syntax to accomplish this.

May I get some help on this.

thank

+5
source share
3 answers

If you just wanted to insert data into new records in a table revenue:

INSERT INTO revenue (receiptno) SELECT receiptno FROM clients;

, revenue clients, UPDATE:

UPDATE revenue JOIN clients ON **join_condition_here**
SET    revenue.receiptno = clients.receiptno;

SQL-.

+11

, eggyal, Oracle Postgress, .

UPDATE revenue t1 SET receiptno = (
  SELECT receiptno FROM clients t2 WHERE t2.client_id = t1.revenue_id
);

where ...

+5
INSERT INTO newtable (field1, field2, field3)
SELECT filed1, field2, field3
FROM oldtable
+1
source

All Articles