views:

208

answers:

1

So I've got:

id    number
 1      0
 2      0
 3      0

Is there a sql statement to copy everything from id into number?

I'm about to write a php scrip to select, then update every row. My SQL knowledge is pretty basic, but I'm sure there's a smart guy way to to do this:

Background: The id used to be a number that was displayed in the app and was unique. That number is no longer unique with some new features I'm adding--so I need to move it to a field that isn't unique while maintaining the integrity of the old.

+6  A: 

You can use an update statement and reference the columns. Just do the following:

update mytable set number = id

That sets number equal to id on each row. Enjoy!

Eric
Wow, that's like ... white belt stuff. I should probably get a book on sql and quit asking such simple questions ...
rpflo