I did a quick search and did not see anything in this forum specific to this problem:
Problem: In one statement (or whatever is most efficient if not possible), how do I update the rows in table A (based on a where clause), and insert into table B, the data from those same number of rows.
For example,
Table A: columns: id , lastName, department, branch
Table B: columns: id, errorMessage, lastName
UPDATE table A by settting branch = 'ETC' where department IS NULL
INSERT INTO table b the rows found in the above UPDATE statement
note: 1.To find the rows UPDATED in the first statement, it is not sufficient to search by branch='ETC', as that will encompass more rows.
2. I do not want to use triggers as these statements will be executed once in the entire process
Thanks!
Problem: In one statement (or whatever is most efficient if not possible), how do I update the rows in table A (based on a where clause), and insert into table B, the data from those same number of rows.
For example,
Table A: columns: id , lastName, department, branch
Table B: columns: id, errorMessage, lastName
UPDATE table A by settting branch = 'ETC' where department IS NULL
INSERT INTO table b the rows found in the above UPDATE statement
note: 1.To find the rows UPDATED in the first statement, it is not sufficient to search by branch='ETC', as that will encompass more rows.
2. I do not want to use triggers as these statements will be executed once in the entire process
Thanks!