tags:

views:

31

answers:

0

I have a table with some data which I create extracts from:

id  data1  data2  data3  data4
-----------------------------
1   foo    bar    baz    foo
2   bar    foo    foo    foo
1   foo    doo    goo    omo

An id might have more than one record in that table. Before giving people a copy of the data, I want to replace all identifiers with something different but keep the records consistent. For example, all records with id = 1 should still have the same identifier in the new table.

Is there an efficient way of doing this in SQL/MySQL? So far, the only thing I have thought of is creating a separate table of ids and manipulating the original ones somehow.

Edit

The output I would like would be:

AAA foo bar baz foo
BSF bar foo foo foo
AAA foo doo goo omo

Essentially, I do only need to obfuscate the id part and replace it with another id that is consistent across the output. i.e. the same source id will get the same replacement id in the output