前景提要
select a.id, c.name as status ,d.name as type from a left join b c on a.status =c.id left join b d on a.type =d.id select a.id, (selct name from b where a.status = b.id) as status, (selct name from b where a.type = b.id) as type from a
a 表与 b 表关联,b 作为字典表,存着名称等信息,a 只有 id 。
不讨论这个表结构改变等等(以及用了很久,数据很多,而且不是我能决定的),仅从 SQL 角度
1.两种写法我都觉得很丑陋,有没有更好的
2.如果没有的话,哪一种稍微好一点