View Single Post
Old 02-18-2013, 08:39 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,162
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
No no...it's easy!

Just do this:
Code:
ALTER TABLE tablename ADD uniqueid INT AUTO_INCREMENT PRIMARY KEY;
And that will not only add the field, make it a primary key, but it will also RIGHT THEN AND THERE populate *ALL* the existing records with the field!

Presto.

(If you want to, after removing the duplicates you could then remove the column, but I wouldn't bother.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 02-18-2013 at 08:47 PM..
Old Pedant is offline   Reply With Quote