FIND_IN_SET() vs IN()

前端 未结 6 788
滥情空心
滥情空心 2020-11-22 06:20

I have 2 tables in my database. One is for orders, and one is for companies.

Orders has this structure:

OrderID     |     attachedCompanyIDs
-------         


        
6条回答
  •  一向
    一向 (楼主)
    2020-11-22 07:17

    To get the all related companies name, not based on particular Id.

    SELECT 
        (SELECT GROUP_CONCAT(cmp.cmpny_name) 
        FROM company cmp 
        WHERE FIND_IN_SET(cmp.CompanyID, odr.attachedCompanyIDs)
        ) AS COMPANIES
    FROM orders odr
    

提交回复
热议问题