0

現在、クエリは Managed_Funds をプルします。私が行きたい2番目のクエリからどのように研究を引き出すのですか? それとも、このビルドは私が望むものに対して十分に進んでいませんか?

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);
?>
4

1 に答える 1

0

クエリは個別に実行する必要があります

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query  = "SELECT ... ";

/* execute multi query */
if (mysqli_multi_query($link, $query)) {...}

$query  = "SELECT ... ";

/* execute multi query */
if (mysqli_multi_query($link, $query)) {...}

/* close connection */
mysqli_close($link);

それともこれですか?

$query  = "SELECT    
       C.DES_CARTERA_CC  Managed_Funds,      
      A.ANOMES_DESDE Date_Since,
      A.ANOMES_HASTA Final_Date,
      A.DES_ESTUDIOS Studies # <------ extra line here
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;
";
于 2012-12-11T22:24:07.710 に答える