FIND_IN_SET() vs IN()

前端 未结 6 857
滥情空心
滥情空心 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:12

    attachedCompanyIDs is one big string, so mysql try to find company in this its cast to integer

    when you use where in

    so if comapnyid = 1 :

    companyID IN ('1,2,3')
    

    this is return true

    but if the number 1 is not in the first place

     companyID IN ('2,3,1')
    

    its return false

提交回复
热议问题