【发布时间】:2017-11-14 12:29:39
【问题描述】:
我在 mysql 中使用两列 userfrom 和 userto 对行进行分组。我只需要选择 a 和 b 之间的一条对话消息。下面的查询完全符合我的要求,但我想将它部署到 android sqlite 查询中,但是 sqlite 只需要 CASE Condition 函数。
SELECT * FROM messeages WHERE userfrom='a' OR userto='a'
group by
IF(userfrom > userto, userfrom,userto),
IF(userfrom > userto, userto,userfrom)
有人可以帮助使用 CASE Condition 函数翻译这个吗?
【问题讨论】:
-
使用
SELECT * ... GROUP IF(userfrom > userto, userfrom,userto), IF(userfrom > userto, userto,userfrom)没有任何意义。 MySQL 假定运行这个错误的查询.. 你的查询真的需要重写。