0

I have an existing Table A with columns c1, c2, c3, c4, c5. I have another Table B with c1, c2, c3.

Table A (c1, c2, c3, c4, c5, C6)

Table B (c1, c2, c3)

I want to introduce a new column in Table A c6 and dump data from Table B c3.

  • Table A c2 and Table B c2 are userid's
  • Table A c2 may have duplicates.

I also want to update insert c6 values for duplicates.

Please help me I wrote below query but it ran for 2 hours did nothing. Table A has 1 million records and Table B has 100 thousand records

I am using HeidiSQL tool to do this update. I was wondering if this is an issue with the tool?

UPDATE Table A
INNER JOIN Table B ON 
Table A.c2 = Table B.c2 
SET Table A.c6 = Table B.c3;
Avi
  • 9
  • 4
  • Your query should work... Try for few records with adding the where clause like "WHERE A.c2 = 1" – Mittal Patel Feb 15 '18 at 05:48
  • Mittal thanks for responding is working for few records but if I run for all the records it is taking long time. – Avi Feb 15 '18 at 06:04
  • 1
    Use explain on the query to see if it uses indexes for joining. Since you want to update 1 million records, it should take a while. – Shadow Feb 15 '18 at 06:16
  • Have you seen [this](https://stackoverflow.com/questions/15209414/how-to-do-3-table-join-in-update-query) ? – Pedram Feb 15 '18 at 07:10

0 Answers0