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
Post a Comment