Answer the question
In order to leave comments, you need to log in
How to update a column of one table with a value from another?
I have two tables, table1 and table2. I need to update the fee column in table2 with the value of the komissiya column from table1, where the values in the transaction table1 column are equal to transaction table2.
UPDATE table2
SET fee = (SELECT table1.komissiya FROM table1
WHERE table1.transaction = table2.transaction);
Answer the question
In order to leave comments, you need to log in
UPDATE table2
INNER JOIN table1 ON table1.transaction = table2.transaction
SET table2.fee = table1.komissiya
INSERT INTO `table1` SELECT * FROM `table2`;
This simple query will take data from table2 and insert it into table1
INSERT INTO `table1`(`row1`, `row2`, `row3`) SELECT `row1`, `row2`, `row3` FROM `table2`;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question