米
心情
所有
图集
登录
搜索
原创
tp6中case、when、else、end的用法
只为过往的红颜
发布于:2021-04-26
case、when、else、end是常见的操作,这里给一个demo ``` $res = Db::name("session_detail") ->alias("a") ->join("user_session b", "b.id = a.sess_id", "left") ->join("staff s", "b.cust_id = s.account", "left") ->join("user_info c", "b.u_cust_id = c.cust_id", "left") ->join("access acc", "b.access_id = acc.id", "left") ->join("robot r", "acc.robot_id = r.id", "left") ->where(["a.sess_id" => $id]) ->where("a.evaluate_msg_type", "IN", "(0, 8, 9, 100)") ->field("a.id as session_detail_id,a.content, a.state, a.msg_type, a.sess_id, a.create_time,a.msg_key,b.u_cust_id as to_id, CASE a.send_from WHEN 4 THEN acc.head_img WHEN 5 THEN r.img WHEN 1 THEN c.headimgurl WHEN 3 THEN c.headimgurl ELSE s.profile END headimgurl, CASE a.send_from WHEN 4 THEN '系统消息' WHEN 5 THEN r.name WHEN 1 THEN c.nickname WHEN 3 THEN c.nickname ELSE s.nickname END nickname, a.send_from, a.evaluate_msg_type ") ->select(); ```
注:原创不易,转载请注明出处(
https://micuu.com/new/1531.html
),本站所有资源来源于网络收集,如有侵权请联系QQ245557979进行清除。
最后修改与 2022-02-22
上一篇:
git常用命令,新建分期合并到dev分支
下一篇:
layui结合Vue使用,初始化layui.use解决办法
留言反馈
请先登录
问题反馈渠道,如有软件无法下载或者其他问题可反馈。【由于某种原因,目前留言不展示】
用户需要登录后才能留言反馈
立即留言
珍藏视频
10分钟高效燃脂
30天高效瘦脸操
5分钟缓解颈椎操
友人
微博
全民K歌
唱吧
今日头条
悠悠网
科技小锅盖
彼岸桌面
阮一峰
laravel社区
V2ex
掘金
更多>