Thomas Spahni wrote:
Hi suomi,

it can be done with a temporary table. See the following example.

Regards,
Thomas Spahni

<snip>
CREATE TEMPORARY TABLE duptemp SELECT * FROM duprows WHERE id = 2;
ALTER TABLE duptemp CHANGE id id INT NULL;
UPDATE duptemp SET id = NULL;

INSERT INTO duprows SELECT * FROM duptemp;
<snip>

So long as you replace 'id' with the name of your primary key column, this has the advantage of working regardless of which column is the primar key. If we can also assume the primary key is in column 1, then we can shorten this slightly:

  CREATE TEMPORARY TABLE duptemp SELECT * FROM duprows WHERE id = 2;
  ALTER TABLE duptemp DROP COLUMN id;

  INSERT INTO duprows SELECT NULL, duptemp.* FROM duptemp;

again replacing 'id' with the name of your pk column.

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to