I have customers table and sometimes update his account i want to add old data to anthor table before update

closed as unclear what you're asking by sp_BlitzErik, hot2use, Colin 't Hart, RDFozz, ypercubeᵀᴹ Sep 14 at 17:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to DBA.SE. You should add more detail/clarity or this question may be closed as unclear or too broad. Do you only sometimes want to keep old versions, or only sometimes make updates but always want to keep old versions in the other table? If the former what logic dictates if you keep the old data or not? It might be helpful to include basic data layout information too: such as "the data is like <sample data>, and when I do <this SQL> as well as the data in <table> now looking like <sample data> the following should be added to <other table> as well: <sample data wanted in table 2>" – David Spillett Sep 14 at 14:06
  • Or, perhaps you mean, "Sometimes a customer account is updated. When this happens, I want to capture the data existing before the update in another table." If so, see this answer from Stack Overflow, and the answers to this one, for how to set up temporal tables. – RDFozz Sep 14 at 15:18
  • Possible duplicate of how to enable temporal database capability in mysql.? – RDFozz Sep 14 at 15:20
  • I thought the question was clear - he wants to audit changes to the customer table. My answer is: create another table with column definitions matching the columns you wish to audit (and from your question I think you have this already); step 2 = add a trigger to your customer table (on/before delete). In that trigger, have a statement that inserts the changing data into your audit table. – youcantryreachingme Sep 17 at 6:55

Browse other questions tagged or ask your own question.