Let's suppose I have a mysql database with sensitive information and I would like to make a shuffle on some data such as swapping values from the lastname column by values from the same column only from another user.
Note: the database will be used by the developers and I do not want them to have access to the true information so those suggestions using select would not solve, I saw that Soft DataVeil does this but not in mysql
Example User1 receives lastname from user4
Orginal data
Fristname | Lastname
user1 | lastname1
user2 | lastname2
user3 | lastname 3
user4 | lastname4
user5 | lastname5
Shuffle mode
Fristname | Lastname
user1 | lastname4
user2 | lastname5
user3 | lastname2
user4 | lastname1
user5 | lastname3
Note: I tried to use the dataveil for this but apparently it does not do shuffle in mysql
If you dont mind duplicates in the Lastname column
You can do it with a simple subquery with a random order and limit.
Query
Possible result
View on DB Fiddle