SELECT CASE WHEN t.name_a != ''
THEN t.name_a
WHEN t.name_b != ''
THEN t.name_b
ELSE t.user_id END
FROM
(SELECT
c.user_id,
a.name_a,
a.phone_a,
u.name_u,
u.phone_u
FROM company c
LEFT JOIN admin a ON c.id = a.company_id
LEFT JOIN user u ON c.user_id = u.id) t
MySQL CASE WHEN 根据一个表的字段值不同关联查询两张不同的表【子查询】
最新推荐文章于 2021-09-10 19:24:38 发布