作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试创建一个讨论系统,使用 SQL 按时间排序显示两个用户之间的消息,例如,如果用户 10 想查看他与用户 45 的消息,这是我的表结构:
消息( id(PK)、sender_id(FK_USER)、receiver_id(FK_USER)、主题、内容、created_at、updated_at);
我尝试了这个 sql 查询,但它没有显示我想要的内容:
select s.id,
s.subjet,
d.source_id as `source`,
d.id,
d.subject
from messages s,
messages d
where s.destination_id=d.source_id
and d.source_id=s.destination_id
and s.source_id=202
order by created_at asc;
最佳答案
如果我正确理解您的表结构和要求,您可以尝试如下 -
SELECT *
FROM MESSAGES
WHERE SENDER_ID IN (10, 45)
AND RECEIVER_ID IN (10, 45)
ORDER BY CREATED_AT
或者像这样 -
SELECT *
FROM MESSAGES
WHERE (SENDER_ID = 10 AND RECEIVER_ID = 45)
OR (RECEIVER_ID = 10 AND SENDER_ID = 45)
ORDER BY CREATED_AT
默认情况下,排序将以 ASC 方式完成,因此无需提及。
关于mysql - 留言讨论查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37005634/
这是一个关于 Yii2 中 RBAC 使用的问题。 到目前为止,我发现它工作得相当好且令人满意,但是我缺少一个关键功能:Yii2 规则提供“反馈”的能力与 Yii2 验证器设置错误消息以解释验证失败的
(仅供引用 - 我是新 ASB) 有关 Azure 服务总线的几个问题: 如何从队列中获取消息但将其保留在那里直到其 TTL 过期?我本以为只要不调用 CompleteMessageAsync 就可以
<!--网站目录 <divclass="function"id="divCatalog"&
我正在使用 Twilio 调用我的客户以提醒他们某些日期。由于有些人不接听这些电话,我想让我的 Twilio 在他们的答录机上留下语音消息。 那可能吗?如果是如何? 谢谢 最佳答案 来自关于 IfMa
我是一名优秀的程序员,十分优秀!