sql - Run UPDATE query for every row in another SELECT -


i have sql query can return 0 let's 20 results. here example:

select value_id table1 t1 inner join table2 t2 on .... inner join table3 t3 on .... .... 

then, want run each value_id update query. let's say:

update table4  set new_value = 1  value_id in (select value_id table1 t1 inner join table2 t2 on .... inner join table3 t3 on .... ....) 

can subquery work on this? performance efficient or there way?

your query fine. performance depends on how database structured. instance, if select runs fast, update should pretty fast (not fast: there more overhead update).

so, answer question is: yes, subquery can work this. test select version (with table4) idea of affect on performance.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -