user4173735
user4173735

Reputation:

insert multiple rows mysql from another table

I tried this function does not work me.

$clv = Execute("SELECT `id_propiedades` FROM `propiedades` WHERE `gestor`=2 ORDER BY `propiedades`.`id_propiedades` ASC");
$estado = "1";
foreach (array($clv) as $valor) {   
$row_data[] = "('$valor','$estado')";
}
$sInsertSql3 = " INSERT INTO `cuotas` (`clv_cuota` ,`estado`) VALUES".implode(',', $row_data);
$GLOBALS["conn"]->Execute($sInsertSql3);

I get this error: Catchable fatal error: Object of class mysqlt_driver_ResultSet could not be converted to string in ...

any suggestions

Upvotes: 0

Views: 1122

Answers (1)

Philip Adler
Philip Adler

Reputation: 2206

I would try the single query:

'INSERT INTO cuotas (cuotas.clv_cuoata, cuotas.estado) SELECT propiedades.id_propiedades, 1 FROM propiedades WHERE gestor=2 ORDER BY propriedades.id_propiedades ASC'

Upvotes: 2

Related Questions