mysql数据库关联表查询 find_in_set 与GROUP_CONCAT 结合

SELECT 
 T.ID
,T.TITLE
,T.RELEASE_USER_NAME
,T.RELEASE_DEPARTMENT_NAME
,T.RELEASE_DATE
,T.KEYWORD
,D2.DIC_NAME CATEGORY
,T.CASE_ABSTRACT
,T.CASE_TEXT
,GROUP_CONCAT(distinct  SD.DEPARTMENT_NAME ) as 'SUPPORT_DEPARTMENTS'
,GROUP_CONCAT(distinct  SP.PRODUCT_NAME ) as 'SUPPORT_PRODUCTS'
,T.ATTACHFILES
,D1.DIC_NAME  MJ
,T.CREATE_TIME
,T.UPDATE_TIME
,T.STATUS
,T.DEL_STATUS 
FROM bmj_typicalcase T
LEFT JOIN PLAT_SYSTEM_DICTIONARY D1 ON T.MJ = D1.DIC_VALUE
LEFT JOIN PLAT_SYSTEM_DICTIONARY D2 ON T.CATEGORY = D2.DIC_VALUE
LEFT JOIN bmj_supportproduct  SP ON FIND_IN_SET(SP.ID , T.SUPPORT_PRODUCTS ) 
LEFT JOIN bmj_supportdepartment SD ON FIND_IN_SET(SD.ID , T.SUPPORT_DEPARTMENTS ) 
WHERE 
D1.DIC_DICTYPE_CODE = 'MJ'
AND D2.DIC_DICTYPE_CODE = 'PRODUCT_TYPE'
GROUP BY T.ID

你可能感兴趣的:(记事本,数据库,mysql)