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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?