当前,查询提取 Managed_Funds。如何从我想要的第二个查询中提取研究?还是这个版本不够先进,无法满足我的要求?
我是 MYSQLi 的新手。
<?php
$ID_CARTERA= '8';
$link = mysqli_connect("localhost","carteras_admin","","carteras_bdcarteras");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT
C.DES_CARTERA_CC Managed_Funds,
A.ANOMES_DESDE Date_Since,
A.ANOMES_HASTA Final_Date
FROM det_personas_carteraadmin A
JOIN mcarteras B ON ( A.ID_PERSONA = B.COD_ADMINISTRADOR )
JOIN mcarteras C ON ( C.ID_CARTERA = A.ID_CARTERA )
WHERE A.ID_PERSONA = B.COD_ADMINISTRADOR
AND A.`ANOMES_HASTA` <> 'A Hoy'
AND B.`ID_CARTERA` = $ID_CARTERA;
";
$query .= "SELECT A.DES_ESTUDIOS Studies
FROM det_personas_estudios A
JOIN mcarteras B ON ( A.ID_PERSONA = B.COD_ADMINISTRADOR )
WHERE B.ID_CARTERA = $ID_CARTERA
";
/* execute multi query */
if (mysqli_multi_query($link, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_array($result)) {
printf("%s\n", $row['Managed_Funds']);
}
mysqli_free_result($result);
}
/* print divider */
if (mysqli_more_results($link)) {
printf("-----------------\n");
}
} while (mysqli_next_result($link));
}
/* close connection */
mysqli_close($link);
?>