copy field from one table to another

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VooDoo

    #1

    copy field from one table to another

    Hi,
    i am trying to copy a completed field set from one table to another.
    I am using this SQL command:
    INSERT INTO doc_valid SELECT * from doc_temp where id=$id

    it works, but it also copy the index field id from my temp table to the
    valid table...
    the index are autoincrement primary key, and it should take the next index
    value....

    How can i make this copy and use the auto incremental index of the
    destination table??



  • Jerry Stuckle

    #2
    Re: copy field from one table to another

    VooDoo wrote:
    Hi,
    i am trying to copy a completed field set from one table to another.
    I am using this SQL command:
    INSERT INTO doc_valid SELECT * from doc_temp where id=$id
    >
    it works, but it also copy the index field id from my temp table to the
    valid table...
    the index are autoincrement primary key, and it should take the next index
    value....
    >
    How can i make this copy and use the auto incremental index of the
    destination table??
    >
    >
    >
    >
    Ask in comp.databases. mysql. This has nothing to do with PHP.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • =?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=

      #3
      Re: copy field from one table to another

      VooDoo wrote:
      Hi,
      i am trying to copy a completed field set from one table to another.
      I am using this SQL command:
      INSERT INTO doc_valid SELECT * from doc_temp where id=$id
      >
      it works, but it also copy the index field id from my temp table to
      the valid table... the index are autoincrement primary key, and it
      should take the next index value....
      >
      How can i make this copy and use the auto incremental index of the
      destination table??
      Although this question has more to do with MySQL than PHP, and should
      rather have been posed in comp.databases. mysql, you might try
      specifying the field names you want to extract from the temp table
      instead of * (which means ALL fields, including the "id" field).

      --
      Kim André Akerø
      - kimandre@NOSPAM betadome.com
      (remove NOSPAM to contact me directly)

      Comment

      Working...