I have a function that updates three tables, but I use three queries to perform this. I wish to use a more convenient approach for good practice.
How can I update mu
Let's say I have Table1
with primary key _id
and a boolean column doc_availability
; Table2
with foreign key _id
and DateTime column last_update
and I want to change the availability of a document with _id
14 in Table1
to 0 i.e unavailable and update Table2
with the timestamp when the document was last updated. The following query would do the task:
UPDATE Table1, Table2
SET doc_availability = 0, last_update = NOW()
WHERE Table1._id = Table2._id AND Table1._id = 14