我在数据库中有两个表:
帖子表
id|name|message|time
通知表
id|name|initiator|type|message|time
我想要的是两个输出两个表混合而不是一个接一个。
像这样:
Simon: Reebal want to be friends? 5 minutes ago
Reebal: Yeah sure. 4 minutes ago
Simon and Reebal are friends now (notification)
Reebal: How are you? 2 minutes ago
Simon: Fine and you? 1 minute ago
不是这样的:
Simon and Reebal are friends now (notification)
Simon: Reebal want to be friends? 5 minutes ago
Reebal: Yeah sure. 4 minutes ago
Reebal: How are you? 2 minutes ago
Simon: Fine and you? 1 minute ago
这有可能吗?我希望你明白我的意思? 请不要提供完整的代码,只是对正确方法的建议。
最佳答案
建议:
您应该在两个查询中使用联合来获得结果。
UNION 关键字
关于php - 一个查询中有两种不同的帖子类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45613511/