I have a table in database with a few triggers on it so every time an entry is updated or deleted it send a shadow copy to a log table before actually making changes in current table and it's working perfect.

What i want to do is find the changed columns e.g when i update a record it sends a shadow to log table and showing both records with all columns doesn't provide user with a proper view cause number of columns is more than 25.

I need a solution that shows customer meaningful output like which column was changed and what was the previous record and what's the current value of that column.

The solution i have come up with so far is to convert all rows in a single table using union but that's not a good view for user.

An Example of record set.Record Set For Log

In the following image first record is the actual one and other two are from log table.

  • If you are using MySQL 8.0 or a recent MariaDB, see LAG(). – Rick James Apr 22 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.