doumen5895 2015-05-28 21:44
浏览 121
已采纳

MySql:如何从表中删除行除了具有特定ID的行

I have an html table with checkboxes. Users are permitted to delete rows from that html table except one specific one, whose value is hard coded in the DB.

If a user accidently checks it regardless, I want my server code (php) or even better the MySqL to run a delete query for all the rows they checked EXCEPT for that 1 specific row. So,something like this( which is wrong):

DELETE FROM table_name
WHERE row_id = some_value
EXCEPT row_id = some_value; 

Many thanks !

  • 写回答

2条回答 默认 最新

  • dongzhi1904 2015-05-28 22:25
    关注

    DELETE FROM table_name WHERE row_id NOT IN (do_not_delete_this_value );

    do_not_delete_this_value will be the id of the row you don't want to delete, rest all records will get deleted.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大