mysql case when 用法
最近在做一个 IM 聊天APP,一个功能是获取聊天用户列表。
select *,
case
when s_user=${user_id} then r_user
else s_user
end as partner_id
from
t_msg
where
(t_msg.s_user = ${user_id} or t_msg.r_user = ${user_id})
and
t_msg.is_group = 0
最近在做一个 IM 聊天APP,一个功能是获取聊天用户列表。
select *,
case
when s_user=${user_id} then r_user
else s_user
end as partner_id
from
t_msg
where
(t_msg.s_user = ${user_id} or t_msg.r_user = ${user_id})
and
t_msg.is_group = 0