Tuesday, August 25th 2009

Blanking out Credit Card numbers in a database with XXXX
posted @ 6:01 am in [ Uncategorized ]

If you have a database table of Credit Cards that a customer has forgotten to mask or blank out, this simple SQL statement will nuke the first 12 digits so that only the last 4 remain as a reference for what card was used = safe 🙂

UPDATE orders SET cc_number = CONCAT(‘XXXXXXXXXXXX’, SUBSTRING(cc_number, 12, 4));

[Change orders to be your table]