我的问题是:
我有这样的数据库:
| from | to | time | text | read |
| hans | poul | 0916 | hi there | 1 |
| john | poul | 1033 | waz up | 1 |
| hans | john | 1145 | new text | 0 |
| poul | john | 1219 | message | 0 |
| poul | hans | 1233 | respond | 0 |
我想要一个输出,其中每个“from”或“to”都有“hans”列出,分组并按时间顺序排列:
poul - 1233 - respond - 0
john - 1145 - new text - 0
答案 0 :(得分:-1)
您的SQL查询可能是: -
select * from `table_name` where (`from` ='hans' or `to` ='hans') group by `from`, `to` order by time desc
如果您发现任何困难,请回复。