I am trying to write a couple of queries in MySQL that needs to perform the following: The query here will return all the records that meet caseid=702 with a join from another table.
SELECT db.tab1.id as id
FROM db.tab1 JOIN db.tab2
ON db.tab1.caseid = db.tab2.padid
WHERE db.tab1.caseid=702
I want to take the output of this query and insert as an array to an UPDATE statement for another table t3.
How do I do that on MySQL? I have read few resources on Cursor or do I have to write stored procedure for it?
Thanks
What about:
update table_a set col1 = value1
where id in (
SELECT db.tab1.id as id
FROM db.tab1 JOIN db.tab2
ON db.tab1.caseid = db.tab2.padid
WHERE db.tab1.caseid=702
);
Second round: I took the liberty of refactoring you query. I hope it helps:
update evou e
set status = 1234
where vid in (
SELECT vid
FROM pay p
where p.resoncode = 222
and p.vid = e.vid
)
and e.status=70006