SELECT * from (SELECT id,userId,type,DATE_FORMAT(payTime, '%Y-%m-%d %H:%i:%s' ) as payTime
,IFNULL((SELECT username from sys_user where sys_user.user_id = tb_order.userId),"") as username
,(case type when '1' then (SELECT name from tb_member_goods where tb_member_goods.id = tb_order.memberGoodsId)
when '2' then (SELECT courseName from tb_courses where tb_courses.courseId = tb_order.courseId)
else '其他' end ) goodsName
FROM `tb_order`) t
case then 用法
于 2023-10-24 11:33:12 首次发布
本文介绍了如何通过SQL从订单表获取详细信息,包括用户、商品名,以及关联其他表的操作。
摘要由CSDN通过智能技术生成