Addie Baker
asked on
Update parent table id from old table that has relation
I am creating new tables in my database because im trying to normalize them.
I am having to update these new tables with my old data.
i have populated tbl_activity and tbl_class from results_class table
I have also populated tbl_activity_class with all the class id's from tbl_class.
Now i need to update tbl_activity_class with my activity_id's from tbl_activity.
results_class has the right relationships between activity and class
How can i update tbl_activity_class activity_id from tbl_activity activity_id where results_class activity and class match class_id of tbl_class.
hope i explained this well enough.
looks pretty basic, do you have indexes on those columns you are joining on?
Try doing left joins for this insert, then delete rows with null you don't want after. that might go faster.
Try doing left joins for this insert, then delete rows with null you don't want after. that might go faster.
ASKER
i have index on results_class activity and class unique.
What might that look like?
What might that look like?
Instead of inner join use left join
ASKER
I tried left and it takes longer to run select query.
With either inner or left when I add insert the query takes forever then times out. What are my options?
I'm using dbforge
With either inner or left when I add insert the query takes forever then times out. What are my options?
I'm using dbforge
are you truncating the table first?
ASKER
The tmp table I'm inserting to? Yes. It's empty
I'm out of ideas, it's a simple query, not much to optimize. I suppose it could be running out of memory or something.
ASKER
Hmm. Im not sure what's going on. The tables are both over 100k rows.
I'll post more details and sample data when I get to pc
I'll post more details and sample data when I get to pc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
However its taking forever to execute. Is there a quick way to run this query?
Open in new window