mysql - Is this the wrong way to go about updating a table -


i wrote code try update q_id column of table q_id values of table b. feel if inefficient , wrong way go because it's taking long time run. there better way this?

update tbl1 a,tbl2 b set a.q_id = b.q_id   a.col not null ,     a.col = b.col 

your query equivalent to:

update tbl1 join        tbl2 b        on a.col = b.col     set a.q_id = b.q_id; 

the comparison null unnecessary.

however, not performance. index on tbl2(q_id, col) should performance considerably.

if updating lots of rows (says hundreds of thousands or more), have deal logging issues. in case, breaking update multiple steps might wise option. also, if there multiple matches each record in tbl1, might slow down query.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -