03/17/2023 07:16 AM
Hi,
There is a requirement that we need to retrieve the userdata which got modified with file upload.
The below query works to get all the users who got updated(even if there is no change in data). But we need only the users whose data(firstname or lastname, etc.) is modified.
select USERNAME, FIRSTNAME, LASTNAME, SAVUPDATEDATE as 'UPDATE DATE' from users where SAVUPDATEDATE>CURDATE()
Is there any possibility to retrieve data in this way?
Best regards
Harish
03/17/2023 06:26 PM
Hi @HarishG ,
From the latest version onwards, there is a column changelog in usershistory table which you can utilize to check lastname/firstname updates.
Try the below query -
SELECT
u.username, u.firstname, u.lastname, uh.changelog
FROM
users u
INNER JOIN
usershistory uh ON u.userkey = uh.userkey
WHERE
u.SAVUPDATEDATE > CURDATE()
AND uh.changelog LIKE '%firstname%'
OR uh.changelog LIKE '%lastname%';