MySQLi选择查询相关记录

MySQLi选择查询相关记录,mysql,select,Mysql,Select,好的,我已经编辑了我的消息,并按照您的回复中的建议包含了第二个查询的代码。我还包括了一个对结果的预期的屏幕截图;即: 罪犯的照片和生物数据 在第一个SELECT查询语句中链接到罪犯的任何其他罪犯的照片 这是你的建议吗 <?php //The first working MySQLi SELECT statement is here ..... } /* Close the statement */ $stmt->close(); } else {

好的,我已经编辑了我的消息,并按照您的回复中的建议包含了第二个查询的代码。我还包括了一个对结果的预期的屏幕截图;即:

  • 罪犯的照片和生物数据
  • 在第一个SELECT查询语句中链接到罪犯的任何其他罪犯的照片
  • 这是你的建议吗

    <?php
     //The first working MySQLi SELECT statement is here .....
    
        }
    
        /* Close the statement */
        $stmt->close();
    }
    else {
        /* Error */
        printf("Prepared Statement Error: %s\n", $mysqli->error);
    }
    
        if ($stmt = $mysqli->prepare("SELECT PersonID,ImagePath FROM t_persons 
                    NATURAL JOIN t_incidents
                    NATURAL JOIN t_incident_persons 
            WHERE t_persons.PersonID = '$PersonID' AND t_incident_persons.IncidentID = t_incident.IncidentID")) {   
    
        /* Execute the prepared Statement */
        $stmt->execute();
    
        /* Bind results to variables */
        $stmt->bind_result($PersonID,$ImagePath);
    
        /* fetch values */
        while ($rows = $stmt->fetch()) {
         // display records in a table
         <?php echo '<img src="./Persons_Images/'.$ImagePath.'" width="300" height="400" border="1" />';  ?>
         }
         }
    /* close our connection */
    $mysqli->close();
    ?>  
    
    
    对表执行自然联接


    你能写出你的预期产出吗?
    select ('coulmns in need') from t_persons natural join t_incidents natural join t_incident_persons;