Why not just use something like:
insert into questions (field1,field2,...) select...
You don't need to create temp tables for your data and all the other
complicated stuff.
> hello .
> i use php 4.12 + mysql 3.23.49 on linux .
> i've developed a online testing(quiz) -aplication that now is expected to
> behave somehow different from what i've had in mind at the begining . More
> exactly :
>
> i have 3 tables (MyIsam):
>
> 1. tests (id,name,desc)
> 2. questions (id,id_test_fk,desc)
> 3. answer(id,id_q_fk,desc,points) .
>
> i want to copy a question from one test to another .
> If i knew that from the start , i would have designed the tables differntly
> , but that's another problem .
> the point is i'm trying to do a 'quick_and_dirty' patch like this :
> ----------
> set @test_id=$test_target;
> set @q_id=$qid;
>
> create temporary table q_temp as select * from questions;
> create temporary table ans_temp as select * from answers;
>
> insert into questions select
> '',@test_id,t2.q_type,t2.description,t2.dimension,t2.combination,t2.checkit
> from q_temp as t2 where id=@q_id;
> select @last:=LAST_INSERT_ID();
> insert into answers select '',@last,score,description from ans_temp where
> id_question_fk=@q_id;
> ------
> where $test_target and $qid are given from php .
>
> my problem is that this query works and dows what is expected when run from
> mysql ,
> but NOT from php . No error , nada . I even tryed to do dirty thing
> (shell_exec('mysql -u user -p password database </tmp/qry.txt')) where
> qry.txt was generated
> by php (containing the above code) but NO luck .
> could you please give a suggestion or ..smth ?
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php