Please note: I am asking the question I want answered. I know this question means the database is set up poorly. So I will vote down any answers that suggest changing the way the table is set up.

I need to duplicate a bunch of rows, while changing one value.

name   col1 col2
dave   a    nil
sue    b    nil
sam    c    5

needs to become:

name   col1 col2
dave   a    nil
dave   a    a
sue    b    nil
sue    b    a
same   c    5

IE for all entries in this table where col2 is null, create a new entry in the table where name and col1 are the copied, and col2 is a.

Edit
Report