Results 1 to 4 of 4
  1. #1

    Moving a row from table A to Table B?

    Is there a easy way to move a row from Table A to Table B in mysql/php.
    Thanks!

  2. #2
    Join Date
    Jun 2002
    Posts
    234
    SQL:

    INSERT INTO tableA SELECT * FROM tableB WHERE id = 1;
    DELETE FROM tableB WHERE id = 1;

  3. #3
    Join Date
    May 2002
    Posts
    638
    is it possible to to copy a record in the same table? for eg. if i want to duplicate a record in the same table.

    i.e. insert into tableA select * from tableA where id = 1;

    is the above code correct?

  4. #4
    Join Date
    Dec 2002
    Location
    Fort Worth
    Posts
    434
    Originally posted by lobaloba9
    is it possible to to copy a record in the same table? for eg. if i want to duplicate a record in the same table.

    i.e. insert into tableA select * from tableA where id = 1;

    is the above code correct?
    In general you should be able to do this, though this is in no way a commentary on whether your syntax is correct. More importantly though, there could be factors that might make this impossible, in particular if there is a unique index on the table; a particularly common type of unique index is associated with an "auto-increment" field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •