douwuli4512 2017-05-12 03:51
浏览 6
已采纳

如果表A中包含的值被删除,如何将表B值(包括在表A中)更改为0

How to solve this problem (mysql table): What PHP code or MySQL that I need to use (when I delete adminid = 1 from table A, the value of adminid table B should change to 0)? Is it possible?

Table A has:

adminid = 1
adminname = jack

Table B has:

newsid = 1
adminid = 1

The TableB.adminid should change to 0 if TableA.adminid = 1 gets deleted.

Thanks!

  • 写回答

2条回答 默认 最新

  • douwei3172 2017-05-12 04:02
    关注

    Through PHP and MySql it's possible if the adminid is not a foreign key in table B (In relationship with table A). Instead of 0 you can make it to null using mysql. There is a SQL command you need to use to enable it: ON DELETE SET NULL.
    Refer this for more detail

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

报告相同问题?

悬赏问题

  • ¥15 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类