如果中间需要+号:select concat(superId,'+',name) as newfield from 部门表 where id='部门Id';
select (select name from 部门表 y WHERE y.id=x.superId),name from 部门表 x where id=??
刚才没看清题意,sorry!改正如下:SELECT CONCAT(IFNULL((SELECT name FROM depinfo a WHERE a.id=b.superid),'一级部门'),'+', name) as supername FROM depinfo b WHERE b.id='search_id';depinfo:部门表 search_id:要查询的id变量
select b.name from 部门表 a,部门表 b where a.superId=b.id and a.id='部门Id';
select concat(b.name,'+',a.name) from 部门表 a,部门表 b where a.superId=b.id and a.id='部门Id';
CONCAT(IFNULL((SELECT name FROM depinfo a WHERE a.id=b.superid),'一级部门'),'+',
name) as supername FROM depinfo b WHERE b.id='search_id';depinfo:部门表
search_id:要查询的id变量