mysql - 如何在网站中实现消息功能

标签 mysql sql message

我有一张 table

____________________________________________________________
|                         Message                           |
|___________________________________________________________|
| Sender  |  Message    |    Receiver       |   message_id  |   
| John    | How Are You?|      Will         |       1       |
|_________|_____________|___________________|_______________|

在Will电脑中我显示如下

Message By:John
Message:How Are You?

现在假设 John 删除了这条消息,但我无法删除该记录,因为 Will 尚未删除。因此我正在运行更新查询

Update Message Set Sender='' where message_id=1;

但这样做之后计算机消息会发生如下变化

 Message By:                    //Because i have changed sender to null
    Message:How Are You?

现在我怎样才能克服这个没有得到想要的输出的错误

最佳答案

只需再维护两列boolean is_deleted(true/false) 和 deleted_by(S/R) 来维护消息状态 deleted (true or false) 和 deleted_by ( 发件人或收件人)。

关于mysql - 如何在网站中实现消息功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10997785/

相关文章:

centos 5.2 上 my.cf 的 mysql 5.6 默认位置

MySQL 日期通配符性能

sql - 当我尝试执行简单查询时,Spark 3 失败

Angularjs - 如何获得 ng-message required 错误以同时显示和禁用输入按钮

html - 我如何创建这个 "fade in message box"

php - 关注者/关注数据库结构

python - (Python) MySQL 数据库身份验证问题

mysql - Doctrine 2 : How to sort by count of an associated entity?

php - 如何自动将当前日期时间添加到我的数据库中

eclipse - Eclipse 可执行启动程序无法找到其配套共享库错误消息