1,第一種node
SELECT `a`.`id`,`a`.`submit_time`,`a`.`house_id`,`a`.`status`,`a`.`type`,`a`.`request`,`a`.`response`,`a`.`expense_customer`,`a`.`expense_company`,
CONCAT(b.real_name,'(',(select `name` from es_department where id in (trim(BOTH ',' FROM b.dept_id))),')' ) AS sale_name,
`b`.`phone`,`f`.`node_name`
FROM `es_bl_ticket_house` `a`
複製代碼
2,第二種bash
SELECT `a`.`id`,`a`.`submit_time`,`a`.`house_id`,`a`.`status`,`a`.`type`,`a`.`request`,`a`.`response`,`a`.`expense_customer`,`a`.`expense_company`,concat_ws('',`b`.`real_name`,'(',d.name,')') AS sale_name,`b`.`phone`,`f`.`node_name`
FROM `house` `a`
LEFT JOIN `staff` `b` ON `a`.`salement_id`=`b`.`id`
LEFT JOIN `department` `d` ON find_in_set(d.id,b.dept_id)
LEFT JOIN `main` `h` ON `a`.`house_id`=`h`.`hid`
LEFT JOIN `dictionary` `hd` ON `h`.`dictionary_id`=`hd`.`cid`
INNER JOIN `workflow_relate_record` `e` ON `e`.`record_id`=`a`.`id`
LEFT JOIN `workflow_record` `f` ON `e`.`workflow_record_id`=`f`.`id`
WHERE `a`.`status` <> '0' AND `e`.`module_id` IN (1004,1005) GROUP BY a.id ORDER BY a.submit_time DESC
複製代碼
select u.id,u.name,group_concat(b.名稱) from u left join b on find_in_set(b.id,u.部門Id) group by u.id;
複製代碼