I have two tables: Table_1 -------------- ID | NAME | AMOUNT 1 | name1 | - 2 | name2 | - 3 | name3 | - 4 | name4 | - 5 | name5 | - Table_2 ID | NAME_ID | AMOUNT 1 | 2 | 5 2 | 3 | 4 3 | 5 | 12 I want to copy amount from table_2 to table_1 where name_id of table_2 and id of table_1 are same. After updating table_1 should look like this: Table_1 -------------- ID | NAME | AMOUNT 1 | name1 | - 2 | name2 | 5 3 | name3 | 4 4 | name4 | - 5 | name5 | 12 Need your help urgently. Thanks in advance.
so let me make sure i get this right.... all you want to do is take the data fields from Table_2 under the section called Amount and transfer them to Table_1 ? How much data do you have to transfer?
Yes you are right. I found the following code is working and tested on small table (20 rows.) UPDATE table_1,table_2 SET table_1.amount=table_2.amount WHERE table_1.id=table_2.name_id Do you think this will be a problem if i have 1000+rows in database.
As long as you are willing to set the values for each line in the query... This will work for any amount of rows. I work with small databases (less than 400 tables), and some larger databases. The biggest database I edit is somewhere around 5700 tables... god knows how many rows is in that thing. The only thing that you will have to watch is your file upload limit... most databases allow the sql files to be about 50mb, some may not allow more than 2mb at a time. Even if you have to break up the queries, if you take the time you can add anything. I have to edit and update 14,000 rows for one table in the next few days.