Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Question Unanswered: Index on 2 different tables

    I searched but I really don't know what I am searching for... but this is what I have...

    I have two tables... 1 has an index the other doesn't...

    when I insert into the one that has the index the index autoincrements... how do I grab that index number in the same insert (or not) so I can reference and insert it in the other table?

    That make sense?

    Thanks !
    Eroc

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If some of your code is providing the values, you'll have to retrieve those yourself. If MySQL is providing them using AUTO_INCREMENT, then you can retrieve the value using LAST_INSERT_ID().

    -PatP

  3. #3
    Join Date
    Aug 2004
    Posts
    2
    Thanks for your reply and getting me started !!!

    Here is what I have:

    Code:
    INSERT INTO phpbb_posts_text (post_id, post_subject, post_text) VALUES ( WHATHERE,'$subject', '$body')
    The field is Auto_Increment(ed) and I even tried:

    Code:
    INSERT INTO phpbb_posts_text (post_subject, post_text) VALUES ( '$subject', '$body')
    but I get: Error adding entry: Duplicate entry '0' for key 1

    Can anyone offer any help?

    thanks,
    Eroc

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Based on that error message, methinks thou need'st mysqlcheck.

    -PatP

Posting Permissions

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