duanlian1960 2015-10-09 22:14
浏览 32

基于PHP中的列数据从MYSQL表中删除多行

I have a table called user_favs like this :

 id | user_id | post_id
 ----------------------
 50 | 291     | 1027
 51 | 10      | 180
 52 | 771     | 1027
 53 | 92      | 133
 54 | 523     | 1027

How would I set up a database query in php to delete all rows that contain post_id 1027?

I know how to do it for single entries :

DELETE FROM user_favs WHERE post_id = 1027

But I don't know how to delete all rows that contain post_id 1027.

Is it something like :

DELETE * FROM user_favs WHERE post_id = 1027

I don't want to try it without knowing in case I mash the whole thing up ;)

  • 写回答

2条回答 默认 最新

  • dqitk20644 2015-10-09 22:17
    关注

    this:

    DELETE FROM user_favs WHERE post_id = 1027
    

    will actually not delete only one row. it will delete all rows that matches the criteria post_id=1027

    评论

报告相同问题?

悬赏问题

  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭