Question
Looping through query to update records
Is there a way to create some sort of a loop to update each
record's last_name in QueryA with that of QueryB to produce QueryC.
I would need to update earch record:
UPDATE posnTable
SET
last_name = '#QueryB.last_name#'
WHERE title_id = #QueryA.title_id#
So, for the first record it would be:
UPDATE posnTable
SET
last_name = 'Adam'
WHERE title_id = 1111
QueryA QueryB
title_id last_name title_id last_name
1111 Zen 5555 Adam
2222 Smith 3333 Brown
3333 Brown 4444 Peterson
4444 Peterson 2222 Smith
5555 Adam 1111 Zen
QueryC
title_id last_name
1111 Adam
2222 Brown
3333 Peterson
4444 Smith
5555 Zen
I would need to update earch record:
UPDATE posnTable
SET
last_name = '#QueryB.last_name#'
WHERE title_id = #QueryA.title_id#
So, for the first record it would be:
UPDATE posnTable
SET
last_name = 'Adam'
WHERE title_id = 1111
QueryA QueryB
title_id last_name title_id last_name
1111 Zen 5555 Adam
2222 Smith 3333 Brown
3333 Brown 4444 Peterson
4444 Peterson 2222 Smith
5555 Adam 1111 Zen
QueryC
title_id last_name
1111 Adam
2222 Brown
3333 Peterson
4444 Smith
5555 Zen