MySQL Forums
Forum List  »  Perl

Help with mysql insert
Posted by: Darius Jokilehto
Date: June 01, 2007 01:23PM

I am making a site in perl and DBI with a mysql backend, and am stuck trying to figure out. I was wondering if I could get any advice from anyone:

Basically I have two tables, quizzes and questions.

Quizzes contains the name of the quiz, the id (which has the auto_increment property) and some other columns that are irrelevant for the sake of this matter.

Questions has the columns question_id, quiz_id, question_number, question and answer. Questions.quiz_id references quiz.id.

The problem is when in perl I add a quiz, the id is automatically generated. So as I would like to keep the name of the quiz non-unique, how do I insert the questions.quiz_id tuple referencing the correct quiz? Is there a way to get the quiz_id generated in the database by the query that inserted the row? I don't think it would be a solution to simply read the last entry from the table, as they might be added concurrently.

I hope what I asked is clear enough, if not I can explain further...

Thanks!

Darius

Options: ReplyQuote


Subject
Written By
Posted
Help with mysql insert
June 01, 2007 01:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.