|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I have a table which contains 3 records. When I display the total number of rows selected, it is 3. But when I try inserting into another table, it only insert one row. Can anybody please help me. $sth = $dbh->prepare("SELECT id FROM tab1 WHERE parentid = '1'"); $sth->execute() $rv = $sth->rows; my @row; while ( @row = $sth->fetchrow_array( ) ) { $sth = $dbh->prepare("INSERT INTO tab2(id) VALUES ('@row')"); $sth->execute() } |
|
#2
|
|||
|
|||
|
Well 1st of all, there's no need to recreate the prepare statement every time, that's why you use a prepare statment.
$sth = $dbh->prepare("INSERT INTO tab2(id) VALUES ('?')"); while ( my @row = $sth->fetchrow_array( ) ) { $sth->execute(@row); } That's not tested, but give it a try. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Select multiple rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|