我正在尝试从另一个表中获取表的一个查询值和相关值。以下是我目前的代码
$stm = $conn->prepare("
SELECT *, COUNT(table3_input_id) AS variationsNo FROM table1
LEFT JOIN table2 ON `table1_id` = `table2_ref`
LEFT JOIN `table3` ON `table2_id`=`table3_input_id`
WHERE `table1_id`=:bindtable1ID
GROUP by `table3_input_id` ORDER by `table1_id` ASC");
$stm->bindValue(":bindtable1ID", $preditcion_id);
$stm->execute();
$inputList = $stm->fetchAll();
foreach ($inputList as $row) {
-- fetch values from table 1
while(....){
-fetch values from table 2 related to table 1
}
}
所以我想列出表2中的值,如果表2中有相关的值,我想在表2中列出它们
谢谢!