我想运行一个提取P_no的sql select查询,然后为它运行更新查询。它总是只更新1个值。
$d=date('Y-m-d');
$qu="select P_no from date_summary where `Nextcall_1`='$d' or
`Nextcall_2`='$d' or `Nextcall_3`='$d' or `Nextcall_4`='$d'
or`Nextcall_5`='$d' or `Nextcall_6`='$d' or `Nextcall_7`='$d' or
`Nextcall_8`='$d' or `Nextcall_9`='$d' or `Nextcall_10`='$d' or
`Nextcall_11`='$d'";
$res=mysqli_query($con,$qu);
if($res && mysqli_num_rows($res)>0)
{
while($row=mysqli_fetch_assoc($res))
{
$p1=$row["P_no"];
$qu="update notification_status set Noti_status='Unchecked' where
P_no=$p1";
$res=mysqli_query($con,$qu);
}
}
答案 0 :(得分:2)
您可以使用in
运算符:
UPDATE notification_status
SET noti_status='Unchecked'
WHERE p_no IN (SELECT p_no FROM date_summary WHERE /* etc... */)