PHP 选择不返回值



我有这段代码,我想在medication table中获取信息并将其显示在account table中的acc_id=medication tableacc_id的位置以及med_timeoftheday='morning'

$postdata = file_get_contents("php://input");
if (isset($postdata)) {
$request = json_decode($postdata);
$User_ID = $request->acccid;
$sql = sprintf("SELECT * FROM account_info
join medication on account_info.acc_id = medication.acc_id 
where account_info.acc_id='%s'",
mysqli_real_escape_string($conn,$User_ID));
$result=$conn->query($sql);
if ($result->num_rows>0)
{   
while($row=$result->fetch_assoc()) 
{$data[]=$row;
}
echo json_encode($data);
}
}

这是我的 TS :

我该怎么做?

提前谢谢你!

尝试这样操作:

SELECT * FROM medication 
INNER JOIN account_info ON account_info.acc_id = medication.acc_id
WHERE medication.med_timeoftheday='morning'

首先,如果您从药物表中选择了数据,请选择第一个药物表,然后使用与客户表连接。

$sql = "SELECT * FROM medication JOIN account_info ON account_info.acc_id = medication.acc_id WHERE medication.med_timeoftheday='morning'";

相关内容

  • 没有找到相关文章

最新更新