我有这个问题,显示订单号,日期,数量,有效,并有来自validpersonel的内部联接名称。我怎样才能做到这一点?我的示例代码如下
include 'dbconnection.php';
session_start();
$id = $_SESSION['id']; //companyid
$p_id = $_SESSION['pId']; //personnelid
//$id = $_GET['p_id']
try{
$sql="Select
ordermain.OrderNo,
ordermain.OrderDate,
validpersonnel.Name,
ordermain.OrderedQTY,
ordermain.Valid
FROM ordermain
INNER JOIN validpersonnel ON ordermain.PersonnelID=validpersonnel.PersonnelID
WHERE ordermain.CompanyID = :id";
$res=$db->prepare($sql);
$res->execute(array('id'=> $id));
//$res = $db->query($sql);
}
catch(PDOException $e)
{
die('There was an error.');
}
$res->setFetchMode(PDO::FETCH_ASSOC);
$result = $res->fetchAll();
var_dump($result);