You can do this with the array_diff_assoc() function in PHP.
Here we have two rows of data in php arrays.
$newValues = array_diff_assoc($afterRow, $beforeRow);
It will return an array in which any column values have been changed or added.
Edit
To do this in MySQL, you will need them in pairs of name values, something like this:
Prefs ---------------------------------------------- UserID TransactionID Name Value ---------------------------------------------- 1 1 Font Sans Serif 1 1 Color Red 1 1 Height 100 1 1 Width 400 1 2 Font Verdana 1 2 Color Red 1 2 Height 100 1 2 Indent 50
TransactionID 1 is the old line, and Transaction ID 2 is the new line:
SELECT * FROM Prefs new LEFT JOIN Prefs old ON new.Name = old.Name AND new.Value = old.Value WHERE UserID = 1 AND new.TransactionID = 2 AND old.TransactionID = 1 AND (old.Name IS NULL OR old.Value IS NULL)
If my logic is correct, you should:
source share