Skip to content
Advertisement

What’s the most efficient way of truncating the names in a first_name and last_name column to 1 character?

What’s the most efficient way of truncating the names in a first_name and last_name column to 1 character?

I have a mysql database that I want to hand off to a developer but I want to partially sanitize the data so that the two name records drop down to just initials.

I tried to modify the varchar to 1 character but mysql will not let me truncate the data, it just throws an error. I am working from a dump of the database before I hand it off. I want to obscure the names without making them all the same.

Advertisement

Answer

But, as Gordon Linoff mentioned, this could be expensive if you have a lot of rows in the table

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement