Web Analytics Made Easy -
StatCounter Inserting identity into table - CodingForum

Announcement

Collapse
No announcement yet.

Inserting identity into table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inserting identity into table

    Hi

    I have 3 tables in my MySQL database - customer question and answer.

    The customer table just contains an ID.

    The Question table contains question id's and question text

    The answer table contains the question ID, answer text and customer id.



    If I want to insert into the two tables - how do i create a new id in the customer table which I can then use in the answer table? can @@identity be used like sql server?

    Thanks

  • #2
    After inserting a new row in costumer (I suppose you used an autonumeric column?) you can use mysql_insert_id() to get the id which MySQL created for you for the next insert-query.

    Saludo
    piz
    www.united-scripts.com
    www.codebattles.org

    Comment

    Working...
    X