Hi, all.
Here is my problem:
Let's say i have table1 with columns a,b,c and table2 with cols x,y,z. Some of columns contain the same type of data from one table to the other, but others are totally different. Both tables have a very large number of rows (~70k).
Now, i need to replicate in table1 a column that exists only in table2, so i create a new column in table1, let's name it d, and i want to conditionally import column z from table2 in column d from table1. Conditionally means where a = x and b=y, for example.
i created this query:
i tested this query on a similar set of tables with a few rows and it does the job, but really slow (took ~1 minute to process 300 rows). I'm sure that if i run it on the 2 big tables it will take forever to complete or may not even finish at all.
any better ideas, faster alternatives ? (deleting and re-creating tables in not an option)
thanks
PS: i use mysql 5.0.26 on Win XP SP2 and MySQL Query Browser. I also tried to query from a PHP script, takes just as much.
Here is my problem:
Let's say i have table1 with columns a,b,c and table2 with cols x,y,z. Some of columns contain the same type of data from one table to the other, but others are totally different. Both tables have a very large number of rows (~70k).
Now, i need to replicate in table1 a column that exists only in table2, so i create a new column in table1, let's name it d, and i want to conditionally import column z from table2 in column d from table1. Conditionally means where a = x and b=y, for example.
i created this query:
Code:
UPDATE table1 SET d = (SELECT z FROM table2 WHERE table1.a=table2.x AND table1.b=table2.y)
any better ideas, faster alternatives ? (deleting and re-creating tables in not an option)
thanks
PS: i use mysql 5.0.26 on Win XP SP2 and MySQL Query Browser. I also tried to query from a PHP script, takes just as much.
Comment