Answer the question
In order to leave comments, you need to log in
How to update a table from another table?
Hello!
There are two tables in different bases. In terms of structure, they are almost the same
database 1
Table Warehouse
Name | Quantity | Note | Column not in database 2
------------------------------------- ----------------
Item1 0 2
Item2 1 2
Item3 3 2
Item4 1 2
database 2
Table Warehouse_archive
Name | Quantity | Note
------------------------------------------------- ----------
Product1 4 2
Product2 2 2
Product3 4 2
Product4 5 2
Number of records: 600 Which name needs to be updated.
From the database 2 database of the Warehouse table with the name field ( Product1, Product3) take the values of the column (Name, quantity) update in database 1 Warehouse_Archive.
Answer the question
In order to leave comments, you need to log in
as an option, for mysql, look here www.mysql.ru/docs/man/INSERT_SELECT.html
just your option
In the receiving database, you can create a foreign table on the table from the source database and then execute the following query in the receiving database.
insert into target_table(col1, col2)
select col1, col2
from source_foreign_table
/* where some condition */
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question