duandun3178 2015-02-26 05:51
浏览 297

我可以在INSERT语句中使用WHERE子句吗?

Is it possible to have a where clause in an insert statement? I can't find any documentation on this. I would like to do something like this:

$yesupdate2 = "INSERT INTO points(ID, 
SID,
WID,
PID) WHERE WID = :WID
VALUES(
:ID,
:SID,
:WID,
:PID)";
$stmt9 = $dbh->prepare($yesupdate2);
$stmt9->bindParam(':ID', $blurb, PDO::PARAM_INT);      
$stmt9->bindParam(':SID', $the_SID, PDO::PARAM_INT);        
$stmt9->bindParam(':WID', $yes_WID, PDO::PARAM_INT);        
$stmt9->bindParam(':PID', $contpoint, PDO::PARAM_INT);     
$stmt9->execute();

}
}
  • 写回答

1条回答 默认 最新

  • douqilin4296 2015-02-26 05:56
    关注

    In an insert statement you wouldn't have an existing row to do a where claues on? You are inserting a new row, did you mean to do an update statment?

    update users set ID=$wblurb and WID=$yes_WID WHERE WID = $wid 
    

    Something like this would help..

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题